-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathschema.ts
80 lines (73 loc) · 2.24 KB
/
schema.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { list } from '@keystone-6/core'
import { allowAll } from '@keystone-6/core/access'
import { text, relationship } from '@keystone-6/core/fields'
import { type Lists } from '.keystone/types'
export const lists = {
Person: list({
access: allowAll,
fields: {
// the person's name, publicly visible
name: text({ validation: { isRequired: true } }),
// since create is omitted on the Priority list, the nested create doesn't exist for this field in the public GraphQL schema
priority: relationship({ ref: 'Priority.person', many: true }),
// since the Nice list is completely omitted, this field doesn't exist in the public GraphQL schema
nice: relationship({ ref: 'Nice.person', many: true }),
},
}),
Priority: list({
access: allowAll,
fields: {
person: relationship({ ref: 'Person.priority' }),
},
// this list is partially omitted -> it will partially be in the public GraphQL schema
graphql: {
omit: {
// query: false, // default allowed
create: true,
update: true,
},
},
}),
Nice: list({
access: allowAll,
fields: {
person: relationship({ ref: 'Person.nice' }),
},
// this list is completely omitted -> it won't be in the public GraphQL schema
graphql: {
omit: true,
},
}),
Naughty: list({
access: allowAll,
fields: {
person: relationship({
ref: 'Person',
// this field is omitted at the field level
// the public GraphQL schema will have a Naughty type, but it will only have an `id` field
graphql: {
omit: true,
},
}),
reason: text({
// this field is omitted at the field level for update operations
// the public GraphQL schema will have a Naughty type, but no update type
graphql: {
omit: {
update: true,
},
},
}),
hiddenReason: text({
// this field is omitted at the field level for update operations
// the public GraphQL schema will have a Naughty type, but no read or update type
graphql: {
omit: {
read: true,
update: true,
},
},
}),
},
}),
} satisfies Lists