Skip to content

Instantly share code, notes, and snippets.

@AdamZaczek
Created April 25, 2017 23:14
Show Gist options
  • Save AdamZaczek/7d9e9eb9d9eb35a25878032debc945ab to your computer and use it in GitHub Desktop.
Save AdamZaczek/7d9e9eb9d9eb35a25878032debc945ab to your computer and use it in GitHub Desktop.
GraphQL Getting Started Code Fragment 4
/* eslint no-underscore-dangle: off*/
/* eslint "arrow-body-style": off */
import {
GraphQLList,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
} from 'graphql';
import USER from './models/user';
import SKILL from './models/skill';
import LEVEL_SKILL from './models/levelSkill';
const User = new GraphQLObjectType({
name: 'User',
description: 'Represents user',
fields: () => ({
_id: { type: GraphQLString },
firstName: { type: GraphQLString },
lastName: { type: GraphQLString },
role: { type: GraphQLString }
})
});
const Query = new GraphQLObjectType({
name: 'ProfileSchema',
description: 'Root of the Profile',
fields: () => ({
helloQuery: {
type: GraphQLString,
description: 'Our first query field!',
resolve: () => {
return 'Hello from GraphiQL';
}
},
users: {
type: new GraphQLList(User),
description: 'Netguru members',
resolve: () => {
return USER.find({}, (err, res) => {
return res;
});
}
}
})
});
const Schema = new GraphQLSchema({
query: Query
});
export default Schema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment