Skip to content

Instantly share code, notes, and snippets.

@rohan-varma
Created September 3, 2016 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohan-varma/48bbe9ca6ab23f9049263506595d0d87 to your computer and use it in GitHub Desktop.
Save rohan-varma/48bbe9ca6ab23f9049263506595d0d87 to your computer and use it in GitHub Desktop.
const pokemonType = new GraphQLObjectType({
name: 'pokemon',
fields: () => ({
id: {type: GraphQLString},
name: {type: GraphQLString},
thumbnail: {type: GraphQLString},
//our favoriteMove is a moveType, which was defined earlier.
favoriteMove: {
type: moveType,
resolve: (parent, _) => moves[parent.id], //defines how this query is fulfilled.
},
//our bestFriend field is a (recursive) pokemonType.
bestFriend: {
type: pokemonType,
resolve: (parent, _) => friends[parent.id],
}
}),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment