Created
April 25, 2017 23:32
-
-
Save AdamZaczek/3cfd237c1557daec0e772620dc6efc7e to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 8
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 Skill = new GraphQLObjectType({ | |
name: 'Skill', | |
description: 'Represents skill', | |
fields: () => ({ | |
_id: { type: GraphQLString }, | |
name: { type: GraphQLString }, | |
skillLevels: { | |
type: new GraphQLList(SkillLevel), | |
description: 'Returns list of levels corrsponding to the skill. It is similar to list of grades for a certain subject in school', | |
resolve: (skill) => { | |
return skill._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