Created
April 25, 2017 23:31
-
-
Save AdamZaczek/fa470bd53356d72d6a606335b3225f61 to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 7
This file contains hidden or 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 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