Skip to content

Instantly share code, notes, and snippets.

@AdamZaczek
Created April 25, 2017 23:31
Show Gist options
  • Save AdamZaczek/fa470bd53356d72d6a606335b3225f61 to your computer and use it in GitHub Desktop.
Save AdamZaczek/fa470bd53356d72d6a606335b3225f61 to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 7
const User = new GraphQLObjectType({
name: 'User',
description: 'Represents user',
fields: () => ({
_id: { type: GraphQLString },
firstName: { type: GraphQLString },
lastName: { type: GraphQLString },
role: { type: GraphQLString },
skillLevels: {
type: new GraphQLList(SkillLevel),
description: 'Returns list of skills for certain user',
resolve: (user) => {
return user._level_skills.map((singleLevelSkill) => {
return LEVEL_SKILL.findOne({ _id: singleLevelSkill }, (err, res) => {
if (err) return err;
return res;
});
});
}
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment