Skip to content

Instantly share code, notes, and snippets.

@zgababa
Last active January 22, 2017 13:29
Show Gist options
  • Save zgababa/6f451972204a576c0d2aac60efee64fc to your computer and use it in GitHub Desktop.
Save zgababa/6f451972204a576c0d2aac60efee64fc to your computer and use it in GitHub Desktop.
'use strict';
const graphql = require('graphql');
const client = require('./pokemon.client');
const pokemonType = new graphql.GraphQLObjectType({
name : 'PokemonType',
fields : {
id : {
type : graphql.GraphQLString
},
name : {
type : graphql.GraphQLString
},
order : {
type : graphql.GraphQLInt
},
img : {
type : graphql.GraphQLString,
resolve : (pokemon) => pokemon.sprites.front_default
}
}
});
module.exports = {
type : pokemonType,
args : {
id : {
type : graphql.GraphQLInt
}
},
resolve : (root, args) => {
return client.getPokemon(args.id);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment