Created
April 25, 2017 23:33
-
-
Save AdamZaczek/3859377729f17f0460031dfdfcfc96e3 to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 9
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 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