-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.js
35 lines (30 loc) · 902 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
'use strict';
const { GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql');
const Query = new GraphQLObjectType({
name: 'Query',
description: 'The root type defines how GraphQL operations begin. It is the entry point to constructing GraphQL queries.',
fields: () => ({
hello: {
type: GraphQLString,
args: {
name: { type:GraphQLString }
},
resolve: (root, args, context) => args.name
}
})
});
const Mutation = new GraphQLObjectType({
name: 'Mutation',
description: 'The mutation type defines how GraphQL operations change data.',
fields: () => ({
toUpperCase: {
type: GraphQLString,
args: {
name: { type:GraphQLString }
},
resolve:(root, args, context) => args.name.toUpperCase()
}
})
});
const schema = new GraphQLSchema({ query:Query, mutation:Mutation });
module.exports = schema;