-
Notifications
You must be signed in to change notification settings - Fork 0
/
object-ref.ts
40 lines (37 loc) · 872 Bytes
/
object-ref.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
import { builder } from "~/builder";
import { UserShape } from "../types";
const User = builder.objectRef<UserShape>("User").implement({
fields: (t) => ({
id: t.exposeID("id", {
nullable: false,
}),
name: t.exposeString("name", {
nullable: false,
}),
}),
});
builder.queryType({
fields: (t) => ({
hello: t.string({
resolve: () => `Hello world!`,
}),
stringField: t.string({
resolve: () => 123,
// resolve: () => "Yes, I am a string!",
}),
floatField: t.float({
resolve: () => "Hi, am I a float?",
// resolve: () => 123.456,
}),
user: t.field({
type: User,
nullable: false,
resolve: () => "Am I a user?",
// resolve: () => ({
// id: "1",
// name: "Tuco Salamanca",
// }),
}),
}),
});
export const schema = builder.toSchema();