-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.js
44 lines (36 loc) · 937 Bytes
/
schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import resolvers from './resolvers.js';
import {GraphQLObjectType,GraphQLString,GraphQLInt,GraphQLSchema,GraphQLList} from 'graphql';
const _ = require('lodash');
import users from './resolvers';
const UserType= new GraphQLObjectType({
name: 'User',
fields:{
age: {type:GraphQLInt},
id: {type:GraphQLInt},
name:{type:GraphQLString} ,
gender: {type:GraphQLString},
label: {type:GraphQLString}
}});
const RootQuery = new GraphQLObjectType({
name: 'RootQueryType',
fields: {
user: {
type: UserType,
args: {id:{type:GraphQLInt}},
resolve (parentValue, args) {
return _.find(users, {id: args.id});
}
},
age: {
type: UserType,
args:{age:{type:GraphQLInt}},
resolve (parentValue, args) {
return _.find(users,{age:args.age});
}
}
}
});
module.exports = new GraphQLSchema ({
query: RootQuery
});
export default GraphQLSchema;