-
Notifications
You must be signed in to change notification settings - Fork 0
/
inject_source_late.gql.go.tpl
341 lines (317 loc) · 9.05 KB
/
inject_source_late.gql.go.tpl
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
{{- $root := .}}
{{- $commentFilterText := "Filter simple datatypes"}}
"""
ID {{ $commentFilterText }}
"""
input IDFilterInput {
and: [ID]
or: [ID]
not: IDFilterInput
eq: ID
ne: ID
null: Boolean
notNull: Boolean
in: [ID]
notin: [ID]
}
"""
String {{ $commentFilterText }}
"""
input StringFilterInput {
and: [String]
or: [String]
not: StringFilterInput
eq: String
eqi: String
ne: String
startsWith: String
endsWith: String
contains: String
notContains: String
containsi: String
notContainsi: String
null: Boolean
notNull: Boolean
in: [String]
notIn: [String]
}
"""
Int {{ $commentFilterText }}
"""
input IntFilterInput {
and: [Int]
or: [Int]
not: IntFilterInput
eq: Int
ne: Int
gt: Int
gte: Int
lt: Int
lte: Int
null: Boolean
notNull: Boolean
in: [Int]
notIn: [Int]
between: IntFilterBetween
}
"""
Filter between start and end (start > value < end)
"""
input IntFilterBetween{
start: Int!
end: Int!
}
"""
Float {{ $commentFilterText }}
"""
input FloatFilterInput {
and: [Float]
or: [Float]
not: FloatFilterInput
eq: Float
ne: Float
gt: Float
gte: Float
lt: Float
lte: Float
null: Boolean
notNull: Boolean
in: [Float]
notIn: [Float]
between: FloatFilterBetween
}
"""
Filter between start and end (start > value < end)
"""
input FloatFilterBetween{
start: Float!
end: Float!
}
"""
Boolean {{ $commentFilterText }}
"""
input BooleanFilterInput{
and: [Boolean]
or: [Boolean]
not: BooleanFilterInput
is: Boolean
null: Boolean
notNull: Boolean
}
"""
Time {{ $commentFilterText }}
"""
input TimeFilterInput {
and: [Time]
or: [Time]
not: TimeFilterInput
eq: Time
ne: Time
gt: Time
gte: Time
lt: Time
lte: Time
null: Boolean
notNull: Boolean
in: [Time]
notIn: [Time]
between: TimeFilterBetween
}
"""
SoftDelete {{ $commentFilterText }}
"""
input SoftDeleteFilterInput {
and: [Time]
or: [Time]
not: SoftDeleteFilterInput
eq: Time
ne: Time
gt: Time
gte: Time
lt: Time
lte: Time
null: Boolean
notNull: Boolean
in: [Time]
notIn: [Time]
between: TimeFilterBetween
}
"""
Filter between start and end (start > value < end)
"""
input TimeFilterBetween{
start: Time!
end: Time!
}
{{- range $objectName, $object := $root.List.Objects}}
{{- if $object.HasSqlDirective}}
"""
{{$object.Name}} Input value to add new {{$object.Name}}
"""
input {{$object.Name}}Input {{$object.InputTypeDirectiveGql}}{
{{- range $entityKey, $entity := $object.InputEntities}}
{{$entity.Name}}: {{$entity.GqlType "Input"}}{{$entity.RequiredChar}} {{$entity.InputTypeDirectiveGql}}
{{- end}}
}
"""
{{$object.Name}} Patch value all values are optional to update {{$object.Name}} entities
"""
input {{$object.Name}}Patch {{$object.InputTypeDirectiveGql}}{
{{- range $entityKey, $entity := $object.PatchEntities}}
{{$entity.Name}}: {{$entity.GqlType "Patch"}} {{$entity.InputTypeDirectiveGql}}
{{- end}}
}
"""
Update rules for {{$object.Name}} multiupdates simple possible by global filtervalue
"""
input Update{{$object.Name}}Input{
filter: {{$object.Name}}FiltersInput!
set: {{$object.Name}}Patch!
}
"""
Add{{$object.Name}} result with filterable data and affected rows
"""
type Add{{$object.Name}}Payload{
{{lcFirst $object.Name}}(filter: {{$object.Name}}FiltersInput, order: {{$object.Name}}Order, first: Int, offset: Int, group: [{{$object.Name}}Group!]): {{$object.Name}}QueryResult!
affected: [{{$object.Name}}!]!
}
"""
Update{{$object.Name}} result with filterable data and affected rows
"""
type Update{{$object.Name}}Payload{
{{lcFirst $object.Name}}(filter: {{$object.Name}}FiltersInput, order: {{$object.Name}}Order, first: Int, offset: Int, group: [{{$object.Name}}Group!]): {{$object.Name}}QueryResult!
"""
Count of affected updates
"""
count: Int!
affected: [{{$object.Name}}!]!
}
"""
Delete{{$object.Name}} result with filterable data and count of affected entries
"""
type Delete{{$object.Name}}Payload{
{{lcFirst $object.Name}}(filter: {{$object.Name}}FiltersInput, order: {{$object.Name}}Order, first: Int, offset: Int, group: [{{$object.Name}}Group!]): {{$object.Name}}QueryResult!
"""
Count of deleted {{$object.Name}} entities
"""
count: Int!
msg: String
}
"""
{{$object.Name}} result
"""
type {{$object.Name}}QueryResult{
data: [{{$object.Name}}!]!
count: Int!
totalCount: Int!
}
"""
for {{$object.Name}} a enum of all orderable entities
can be used f.e.: query{{$object.Name}}
"""
enum {{$object.Name}}Orderable {
{{- range $entityKey, $entity := $object.OrderAbleEntities}}
{{$entity.Name}}
{{- end}}
}
{{- range $m2mKey, $m2mEntity := $object.Many2ManyRefEntities }}
{{$refType := $root.List.PrimaryEntityOfObject $m2mEntity.GqlTypeName}}
"""
Many 2 many input between {{$object.Name}} and {{$m2mEntity.GqlTypeName}}
Filter to Select {{$object.Name}} and set to set list of {{$m2mEntity.GqlTypeName}} PrimaryKeys
"""
input {{$m2mEntity.GqlTypeName}}Ref2{{$object.Name}}sInput{
filter: {{$object.Name}}FiltersInput!
set: [{{$refType.GqlTypeName}}!]!
}
{{- end}}
"""
Order {{$object.Name}} by asc or desc
"""
input {{$object.Name}}Order{
asc: {{$object.Name}}Orderable
desc: {{$object.Name}}Orderable
}
"""
Groupable data for {{$object.Name}}
Can be used f.e.: by query{{$object.Name}}
"""
enum {{$object.Name}}Group {
{{- range $entityKey, $entity := $object.InputFilterEntities}}
{{- if $entity.IsPrimitive }}
{{$entity.Name}}
{{- end }}
{{- end}}
}
"""
Filter input selection for {{$object.Name}}
Can be used f.e.: by query{{$object.Name}}
"""
input {{$object.Name}}FiltersInput{
{{- range $entityKey, $entity := $object.InputFilterEntities}}
{{- if $entity.IsPrimitive }}
{{$entity.Name}}: {{$entity.GqlTypeName}}FilterInput
{{- else}}
{{- if $entity.IsEnum}}
{{$entity.Name}}: StringFilterInput
{{- else }}
{{- if $entity.GqlTypeObj.HasSqlDirective}}
{{$entity.Name}}:{{$entity.GqlTypeName}}FiltersInput
{{- end}}
{{- end}}
{{- end}}
{{- end}}
and: [{{$object.Name}}FiltersInput]
or: [{{$object.Name}}FiltersInput]
not: {{$object.Name}}FiltersInput
}
{{- if $object.SQLDirective.HasQueries}}
extend type Query {
{{- if $object.SQLDirective.Query.Get}}
"""
return one {{$object.Name}} selected by PrimaryKey(s)
"""
get{{$object.Name}}({{range $entryKey, $entity := $object.PrimaryKeys}}{{$entity.Name}}: {{$entity.GqlType "Patch"}}!, {{end}}): {{$object.Name}} {{ $object.SQLDirectiveValues "query" "Get" | join " "}}
{{- end}}
{{- if $object.SQLDirective.Query.Query}}
"""
return a list of {{$object.Name}} filterable, pageination, orderbale, groupable ...
"""
query{{$object.Name}}(filter: {{$object.Name}}FiltersInput, order: {{$object.Name}}Order, first: Int, offset: Int, group: [{{$object.Name}}Group!] ): {{$object.Name}}QueryResult {{ $object.SQLDirectiveValues "query" "Query" | join " "}}
{{- end}}
}
{{- end}}
{{- if $object.SQLDirective.HasMutation}}
extend type Mutation {
{{- range $m2mKey, $m2mEntity := $object.Many2ManyRefEntities }}
"""
Add new Many2Many relation(s)
"""
add{{$m2mEntity.GqlTypeName}}2{{$object.Name}}s(input:{{$m2mEntity.GqlTypeName}}Ref2{{$object.Name}}sInput!): Update{{$object.Name}}Payload {{ $object.SQLDirectiveValues "mutation" "Add" | join " "}}
"""
Delete Many2Many relation(s)
"""
delete{{$m2mEntity.GqlTypeName}}From{{$object.Name}}s(input:{{$m2mEntity.GqlTypeName}}Ref2{{$object.Name}}sInput!): Delete{{$object.Name}}Payload {{ $object.SQLDirectiveValues "mutation" "Delete" | join " "}}
{{- end}}
{{- if $object.SQLDirective.Mutation.Add}}
"""
Add new {{$object.Name}}
"""
add{{$object.Name}}(input: [{{$object.Name}}Input!]!): Add{{$object.Name}}Payload {{ $object.SQLDirectiveValues "mutation" "Add" | join " "}}
{{- end}}
{{- if $object.SQLDirective.Mutation.Update}}
"""
update {{$object.Name}} filtered by selection and update all matched values
"""
update{{$object.Name}}(input: Update{{$object.Name}}Input!): Update{{$object.Name}}Payload {{ $object.SQLDirectiveValues "mutation" "Update" | join " "}}
{{- end}}
{{- if $object.SQLDirective.Mutation.Delete}}
"""
delete {{$object.Name}} filtered by selection and delete all matched values
"""
delete{{$object.Name}}(filter: {{$object.Name}}FiltersInput!): Delete{{$object.Name}}Payload {{ $object.SQLDirectiveValues "mutation" "Delete" | join " "}}
{{- end}}
}
{{- end}}
{{- end}}
{{- end}}