Created
September 3, 2016 11:45
-
-
Save rohan-varma/1f897987fa4d965513cd8a2e5024b4e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Query = new GraphQLObjectType({ | |
name: 'Query', | |
//our server can return pokemon and moves. | |
fields: { | |
pokemon: { | |
type: pokemonType, //the type we defined earlier | |
args: { | |
id: {type: GraphQLString} //an id can be passed in to the query to select the pokemon needed. | |
}, | |
resolve: (_,args) => data[args.id], //uses the id as a key to fulfill the request. Note that if there's no id passed in, | |
//null will be returned. In practice, you may wish to throw an exception or handle this error in some manner. | |
}, | |
move: { | |
type: moveType, | |
args: { | |
id: {type: GraphQLString} | |
}, | |
resolve: (_,args) => moves[args.id], | |
}, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment