-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-object.ts
42 lines (38 loc) · 870 Bytes
/
simple-object.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
import { builder } from "~/builder";
const User = builder.simpleObject("User", {
fields: (t) => ({
id: t.string({
nullable: false,
}),
name: t.string({
description: "The name of the user",
nullable: false,
}),
}),
});
type UserShape = typeof User.$inferType;
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();