Skip to content

Instantly share code, notes, and snippets.

@AdamZaczek
Created April 25, 2017 23:33
Show Gist options
  • Save AdamZaczek/3859377729f17f0460031dfdfcfc96e3 to your computer and use it in GitHub Desktop.
Save AdamZaczek/3859377729f17f0460031dfdfcfc96e3 to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 9
const SkillLevel = new GraphQLObjectType({
name: 'SkillLevel',
description: 'Describes how well user knows certain skill.',
fields: () => ({
_id: { type: GraphQLString },
level: {
type: GraphQLInt,
description: 'Actual skill level, ranked from 1 to 3'
},
favorite: { type: GraphQLBoolean },
user: {
type: User,
description: 'Owner of the skill',
resolve: (skillLevel) => {
return USER.findOne({ _id: skillLevel.user });
}
},
skill: {
type: Skill,
description: 'Rated skill',
resolve: (skillLevel) => {
return SKILL.findOne({ _id: skillLevel.skill });
}
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment