-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathgratsGeneratedSchema.ts
More file actions
52 lines (51 loc) · 1.64 KB
/
Copy pathgratsGeneratedSchema.ts
File metadata and controls
52 lines (51 loc) · 1.64 KB
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
// DO NOT USE DIRECTLY. Prefer the merged schema in `./mergedSchema.ts`.
import { GraphQLSchema, GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLID } from "graphql";
import { user as queryUserResolver } from "./../models.js";
export function getSchema(): GraphQLSchema {
const UserType: GraphQLObjectType = new GraphQLObjectType({
name: "User",
fields() {
return {
firstName: {
name: "firstName",
type: new GraphQLNonNull(GraphQLString)
},
fullName: {
name: "fullName",
type: new GraphQLNonNull(GraphQLString)
},
id: {
name: "id",
type: new GraphQLNonNull(GraphQLID)
},
lastName: {
name: "lastName",
type: new GraphQLNonNull(GraphQLString)
}
};
}
});
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
fields() {
return {
user: {
name: "user",
type: UserType,
args: {
id: {
type: new GraphQLNonNull(GraphQLID)
}
},
resolve(_source, args) {
return queryUserResolver(args.id);
}
}
};
}
});
return new GraphQLSchema({
query: QueryType,
types: [QueryType, UserType]
});
}