-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphql-js.ts
52 lines (49 loc) · 948 Bytes
/
graphql-js.ts
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
45
46
47
48
49
50
51
52
import {
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
GraphQLFloat,
GraphQLID,
GraphQLNonNull,
} from "graphql";
const User = new GraphQLObjectType({
name: "User",
fields: {
id: { type: new GraphQLNonNull(GraphQLID) },
name: {
type: new GraphQLNonNull(GraphQLString),
},
},
});
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: "RootQueryType",
fields: {
hello: {
type: GraphQLString,
resolve() {
return "Hello world!";
},
},
stringField: {
type: GraphQLString,
resolve() {
return 123;
},
},
floatField: {
type: GraphQLFloat,
resolve() {
return "Hi, am I a float?";
},
},
user: {
type: new GraphQLNonNull(User),
resolve() {
return "Am I a user?";
},
},
},
}),
});
export { schema };