Git Product home page Git Product logo

graphql-fun's Introduction

GraphQL Fun

The arrival of GraphQL marks a tectonic shift in the way that APIs are designed and will be designed for many years to come. It's useful to talk about all of GraphQL's serious implications for how we fetch data in our applications, but let's not forget that GraphQL is really fun.

This app demonstrates the core concepts of GraphQL with two fun, interactive activities:

TODO: Extend Example Apps

  • Color Groups: Break up an audience of any size into different groups, assigning each person a color. ๐ŸŽจ
  • WeJay: Pick audience members at random to play a song together. ๐ŸŽน

Have Questions?

Email Eve Porcello.

Want to learn more about GraphQL?

Check out GraphQL Workshop.


Saved Board Queries

query players {
  playerCount
  allPlayers {
    login
  }
}

mutation createPlayer {
  githubAuthorization(code: "TEST_PLAYER") {
    token
  }
}

query current {
  game {
    name
    state
    maxPlayers
    minPlayers
  }
  callout {
    name
    state
  }
}
mutation startPerf {
  startPerfIsRight {
    name
    state
    maxPlayers
    minPlayers
  }
}

mutation startFightJay {
  startFightjay {
    name
    state
  }
}

mutation startFaces {
  startFaces {
    name
    state
  }
}

mutation startSpotlight {
  startSpotlight {
    name
    state
  }
}

mutation startPerfIsRight {
  startPerfIsRight {
    name
    state
    maxPlayers
    minPlayers
  }
}

mutation startPerfIsRightFinal {
  startPerfIsRightFinal {
    name
    state
    maxPlayers
    minPlayers
  }
}

mutation endGame {
  endGame
}

mutation endCallout {
  endCallout
}

mutation endSession {
  end
}

# {
#   "authorization": "Bearer c5480bb8-c1ab-49f2-8ea2-783d76703506"
# }

# {
#   "authorization": "Bearer 8888b5ea-11e4-4d92-84e6-c3891f8e9b3a"
# }

# {
#   "authorization": "Bearer d0ecd0b9-2bed-489b-9c4c-7829099c9efe"
# }

graphql-fun's People

Contributors

eveporcello avatar moontahoe avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

graphql-fun's Issues

Skipping all Tests

Right now we are skipping all test due to a Server in Use issue that is causing them to occasionally fail.

Player: Sign in Waiting State

Once the user has logged in, they should see a message that the game is about to begin.

To Complete

  • React Component
  • Test

Player: WeJay Audience Screen

When the player is assigned as an Audience Member role (i.e. not one of the instrument players) they will see this screen.

references #10: WeJay Audience

Board: Team Faces

When Teams have been assigned, the audience faces on the screen should have a color encircling them.

references #6: Team Mutations + Team Query

To Complete

  • React Component
  • GraphQL Data <Query query={ALL_TEAMS}>
  • Test

Board: Display Audience Animations

When an audience member presses their button during WeJay, their face should animate across the screen.

references #10: WeJay Audience

To Complete

  • React Component
  • GraphQL Data <Mutation mutation={PLAY}> & <Mutation mutation={PAUSE} > <Subscription subscription={PLAYING_MUSIC}
  • Test

Board: WeJay Music Band Members

When the WeJay Game is happening, the audience should see the band members faces on screen and when their buttons are pressed.

To Complete

  • React Component
  • GraphQL Data <Mutation mutation={PLAY}> & <Mutation mutation={PAUSE} > <Subscription subscription={PLAYING_MUSIC}
  • Test

Wejay Play Music from Query

We should be able to leave or refresh the wejay board and have it still play the tracks that the API say are playing.

Incorporate apollo-link-state

Whenever any loading is happening, we want to see the loading component. Right now, when a person logs in, they see the GraphQL Fun logo at the same time as the loading animation.

Follow these steps to close this bug:

  • Set up apollo-link-state
  • Create a resolver and a mutation for loading
  • When loading, only show the loading screen
  • When Logging In, Have GraphQL Logo disappear this.state.signingIn
  • Remove this.state.signingIn

Document Schema

Document the entire schema so the playground looks good when looking at it. But specifically hit these types

  • Player
  • Subscriptions
  • Game, Callout
  • allPlayers, totalPlayers query

Price is Right

  1. Create a mutation for starting the Price is Right game

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  comeOnDown {
    login
    avatar
    name
  }
}
  1. Create a Mutation to Kick Someone out of Game

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  kickOut(login: "1") {
    name
    login
  }
}

Player: Welcome Screen

The welcome screen when people first open the browser and go to graphql.fun.

should contain:

  1. GraphQL Logo & GraphQL Fun Info
  2. Authorized Player Component

To Complete

  • React Component
  • GraphQL Data <Query query={ME}>

Player: Color Screen

When the player's phone gets blasted with a color, it should show up on this screen.

references #6 : Team Mutations + Team Query

To Complete

  • React Component
  • GraphQL Data <Mutation mutation={CREATE_TEAMS}> & <Mutation mutation={DESTROY_TEAMS}>
  • Test

Style: WeJay Audience Screen

When the player is assigned as an Audience Member role (i.e. not one of the instrument players) they will see this screen: #21

Team Mutations + Team Query

  1. Create a mutation for Creating Teams

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  createTeams(count: 2) {
    color
    players {
      name
    }
  }
}
  1. Create a mutation for Destroying Teams

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  destroyTeams
}
  1. Create a Query for Team

To Complete

  • - Write the resolvers to fulfill the query
  • - Write test for the mutation
query {
  Team(color: "red") {
    color
    players {
      login
      name
      avatar
    }
  }
}

First Query

This initial query will query allPlayers including their login, avatar, and name. It will also get the playerCount.

To Complete

  • - playerCount resolver
  • - allPlayers resolver
  • - Test the query
query {
  playerCount
  allPlayers {
    login
    avatar
    name
  }
}

Cant't set Heroku NODE_ENV to production

The Heroku NODE_ENV variable had to be development for this to work... but the Heroku environment is production so we need to be able to set that value without it breaking the app.

When Set to Production the application errors and the output reads:

2018-08-01T01:06:35.616356+00:00 app[web.1]: Error: Cannot find module '/app'
2018-08-01T01:06:35.616358+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:547:15)
2018-08-01T01:06:35.616359+00:00 app[web.1]: at Function.Module._load (module.js:474:25)
2018-08-01T01:06:35.616361+00:00 app[web.1]: at Function.Module.runMain (module.js:693:10)
2018-08-01T01:06:35.616363+00:00 app[web.1]: at startup (bootstrap_node.js:191:16)
2018-08-01T01:06:35.616364+00:00 app[web.1]: at bootstrap_node.js:612:3
2018-08-01T01:06:35.625064+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-08-01T01:06:35.629523+00:00 app[web.1]: npm ERR! errno 1
2018-08-01T01:06:35.631517+00:00 app[web.1]: npm ERR! Exit status 1
2018-08-01T01:06:35.631315+00:00 app[web.1]: npm ERR! [email protected] start: `node .`
2018-08-01T01:06:35.631824+00:00 app[web.1]: npm ERR!
2018-08-01T01:06:35.632037+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.

myTeam Subscription

It's time to let the player know they have been grouped into a team. The myTeam subscription should return the currentUsers team once teams have been created.

type Subscription {
   myTeam: Team
}
subscription {
    myTeam {
        color
        players {
             name
             avatar
        }
   }
}

Filtering

This code is not exactly correct, but we can use it for reference. graphql-yoga came with a withFilter function, I am assuming apollo-server also has this funciton? You can use it to filter thorugh subscriptions and only reply to the current player or something.

export const Subscription = {
     myTeam: {
          subscribe(_, args, { currentPlayer }) {
                  //
                  //  TODO: Obtain the currentPlayer here, can't subscribe to my team unless logged in
                  //

                  return withFilter(
                          (_, { events }, { pubsub }) => pubsub.asyncIterator(events),
                          ({ teams:{event, color} }, { events }, { currentPlayer }) => {
                                 if ((event === 'TEAMS_CREATED') && currentPlayer) {
                                        let theTeam = teams.find(t => t.color === color)
                                        return theTeam && theTeam.players.map(p => p.login).includes(currentPlayer.login)
              }
              return true
            }
        )
          }
     }
}

TODO

  • Setup Playground Test
    • Authorize a fake user
    • Add Token to Header
    • Subscribe to my team
  • Push team information when team has been created
  • Push team information when team has been destroyed
  • Write Tests for this feature

Board: Play WeJay Music

When the WeJay game is going on, music should be playing

references #9: Playing WeJay

To Complete

  • React Component
  • GraphQL Data <Mutation mutation={PLAY}> & <Mutation mutation={PAUSE} > <Subscription subscription={PLAYING_MUSIC}
  • Test

WeJay Audience

  1. WeJay Animate Audience Faces Mutation

To Complete

  • - Write the resolvers
  • - Write test for the subscription
mutation {
  animateFaces
}

Starting and Stopping WeJay

  1. Start WeJay Game

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation start {
  startGame(title: "wejay") {
    title
    playerCount
    tracks {
      name
      instrument
    }
  }
}
  1. End WeJay Game Mutation

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  endGame
}

Split Unit/Functional Tests

Jest is really for unit testing. We are doing more of a functional thing with jest right now. Let's leave the unit tests on the JEST side and setup cucumber for our functional API and Client Testing.

Todo

  • Setup Cucumber
  • Move API Tests to Cucumber
  • Jest Component Test Start
  • Jest Unit Test for both API/Client ready

Board: Price is Right

Price is Right screen for the board. Should have the Price is Right Mutation to call on someone and a Kick Out Mutation to kick someone out.

  • Referencing #7 in the API project

Slides

  • Create Slide Project
  • Create Outline
  • Send to Designer
  • Bitly or git.io file
  • Download Locally

GitHub Authorization

Create a mutation to authorize a user with GitHub.

To Complete

  • - Authorizes fake user in development environment
  • - Authorizes real user in production environment
  • - authorizeWithGithub mutation
  • - me query
  • - logout mutation
  • - Test the authorizeWithGithub mutation
  • - Test the me query
  • - Test the logout mutation

Setup Cucumber

In order to have functional Tests, we need to have the Cucumber Setup Prepared.

TODO

  • Setup main files and Packages
  • Start and Stop the API
  • Start and Stop the Client

related to #52

Player: Sign In With GitHub Button

Sign in with GitHub button for graphql.fun.

Referencing #4: GitHub Authorization

To Complete

  • React Component
  • GraphQL Data <Mutation mutation={AUTHORIZE_GITHUB}>

Playing WeJay

  1. WeJay Performer Play Button Mutation

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  play
}
  1. WeJay Performer Pause Button Mutation

To Complete

  • - Write the resolvers
  • - Write test for the mutation
mutation {
  pause
}
  1. WeJay Playing Music Subscription

To Complete

  • - Write the resolvers
  • - Write test for the subscription
subscription {
  playingMusic
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.