Skip to content

Instantly share code, notes, and snippets.

@AdamZaczek
Created April 25, 2017 23:32
Show Gist options
  • Save AdamZaczek/3cfd237c1557daec0e772620dc6efc7e to your computer and use it in GitHub Desktop.
Save AdamZaczek/3cfd237c1557daec0e772620dc6efc7e to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 8
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