-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_code_db_hook.go.tpl
479 lines (422 loc) · 20 KB
/
generate_code_db_hook.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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
{{ reserveImport "gorm.io/gorm" }}
{{ reserveImport "context" }}
{{- range $import := .Imports }}
{{ reserveImport $import }}
{{- end}}
{{- $root := .}}
{{$hookBaseName := "AutoGql"}}
type QueryName string
type GetName string
type AddName string
type UpdateName string
type DeleteName string
type Many2ManyAddName string
type Many2ManyDeleteName string
const (
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- range $m2mKey, $m2mEntity := $object.Many2ManyRefEntities }}
Add{{$m2mEntity.GqlTypeName}}2{{$object.Name}}s Many2ManyAddName = "Add{{$m2mEntity.GqlTypeName}}2{{$object.Name}}s"
Delete{{$m2mEntity.GqlTypeName}}From{{$object.Name}}s Many2ManyDeleteName = "Delete{{$m2mEntity.GqlTypeName}}from{{$object.Name}}s"
{{- end}}
{{- if $object.SQLDirective.Query.Get}}
Get{{$object.Name}} GetName = "Get{{$object.Name}}"
{{- end}}
{{- if $object.SQLDirective.Query.Query}}
Query{{$object.Name}} QueryName = "Query{{$object.Name}}"
{{- end}}
{{- if $object.SQLDirective.Mutation.Add}}
Add{{$object.Name}} AddName = "Add{{$object.Name}}"
{{- end}}
{{- if $object.SQLDirective.Mutation.Update}}
Update{{$object.Name}} UpdateName = "Update{{$object.Name}}"
{{- end}}
{{- if $object.SQLDirective.Mutation.Delete}}
Delete{{$object.Name}} DeleteName = "Delete{{$object.Name}}"
{{- end}}
{{- end}}
{{- end}}
)
// Modelhooks
type {{$hookBaseName}}HookM interface {
{{$root.HookList "model." "" | join "|"}}
}
// Filter Hooks
type {{$hookBaseName}}HookF interface {
{{$root.HookList "model." "FiltersInput" | join "|"}}
}
{{- $m2mV := $root.HookListMany2Many "model."}}
// Many2Many Hooks
type {{$hookBaseName}}HookM2M interface {
{{$m2mV | join "|"}}
}
// Order Hooks
type {{$hookBaseName}}HookQueryO interface {
{{$root.HookList "model." "Order" | join "|"}}
}
// Input Hooks
type {{$hookBaseName}}HookI interface {
{{$root.HookList "model." "Input" | join "|"}}
}
// Update Hooks
type {{$hookBaseName}}HookU interface {
{{$root.HookList "model.Update" "Input" | join "|"}}
}
// Update Payload Hooks
type {{$hookBaseName}}HookUP interface {
{{$root.HookList "model.Update" "Payload" | join "|"}}
}
// Delete Payload Hooks
type {{$hookBaseName}}HookDP interface {
{{$root.HookList "model.Delete" "Payload" | join "|"}}
}
// Add Payload Hooks
type {{$hookBaseName}}HookAP interface {
{{$root.HookList "model.Add" "Payload" | join "|"}}
}
// Add a getHook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- if $object.SQLDirective.Query.Get}}
// - Get{{$object.Name}}
{{- end}}
{{- end}}
{{- end }}
func AddGetHook[T {{$hookBaseName}}HookM, I any](db *{{$hookBaseName}}DB, name GetName, implementation {{$hookBaseName}}HookGet[T,I]) {
db.Hooks[string(name)] = implementation
}
// Add a queryHook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- if $object.SQLDirective.Query.Query}}
// - Query{{$object.Name}}
{{- end}}
{{- end}}
{{- end }}
func AddQueryHook[M {{$hookBaseName}}HookM, F {{$hookBaseName}}HookF, O {{$hookBaseName}}HookQueryO](db *{{$hookBaseName}}DB, name QueryName, implementation {{$hookBaseName}}HookQuery[M, F, O]) {
db.Hooks[string(name)] = implementation
}
// Add a addHook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- if $object.SQLDirective.Mutation.Add}}
// - Add{{$object.Name}}
{{- end}}
{{- end}}
{{- end }}
func AddAddHook[M {{$hookBaseName}}HookM,I {{$hookBaseName}}HookI, AP {{$hookBaseName}}HookAP](db *{{$hookBaseName}}DB, name AddName, implementation {{$hookBaseName}}HookAdd[M, I, AP]) {
db.Hooks[string(name)] = implementation
}
// Add a updateHook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- if $object.SQLDirective.Mutation.Update}}
// - Update{{$object.Name}}
{{- end}}
{{- end}}
{{- end }}
func AddUpdateHook[M {{$hookBaseName}}HookM, U {{$hookBaseName}}HookU, UP {{$hookBaseName}}HookUP](db *{{$hookBaseName}}DB, name UpdateName, implementation {{$hookBaseName}}HookUpdate[U, UP]) {
db.Hooks[string(name)] = implementation
}
// Add a Many2Many Add Hook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- range $m2mKey, $m2mEntity := $object.Many2ManyRefEntities }}
// - Add{{$m2mEntity.GqlTypeName}}2{{$object.Name}}s
{{- end}}
{{- end}}
{{- end }}
func AddMany2ManyAddHook[U AutoGqlHookM2M, UP AutoGqlHookUP](db *AutoGqlDB, name Many2ManyAddName, implementation AutoGqlHookMany2ManyAdd[U, UP]) {
db.Hooks[string(name)] = implementation
}
// Add a Many2Many Delete Hook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- range $m2mKey, $m2mEntity := $object.Many2ManyRefEntities }}
// - Add{{$m2mEntity.GqlTypeName}}2{{$object.Name}}s
{{- end}}
{{- end}}
{{- end }}
func AddMany2ManyDeleteHook[U AutoGqlHookM2M, DP AutoGqlHookDP](db *AutoGqlDB, name Many2ManyDeleteName, implementation AutoGqlHookMany2ManyDelete[U, DP]) {
db.Hooks[string(name)] = implementation
}
// Add a updateHook
// useable for
{{- range $objectName, $object := .Handler.List.Objects }}
{{- if $object.HasSqlDirective}}
{{- if $object.SQLDirective.Mutation.Delete}}
// - Delete{{$object.Name}}
{{- end}}
{{- end}}
{{- end }}
func AddDeleteHook[F {{$hookBaseName}}HookF, DP {{$hookBaseName}}HookDP](db *{{$hookBaseName}}DB, name DeleteName, implementation {{$hookBaseName}}HookDelete[F, DP]) {
db.Hooks[string(name)] = implementation
}
// Interface description of a getHook
// Simple you can use DefaultGetHook and only implement the hooks you need:
// type MyGetHook struct {
// DefaultGetHook[model.Todo, model.TodoInput, model.AddTodoPayload]
// }
// func (m MyGetHook) BeforeCallDb(ctx context.Context, db *gorm.DB, data []model.Todo) (*gorm.DB, []model.Todo, error) {
// //do some stuff
// return db, data, nil
// }
type {{$hookBaseName}}HookGet[obj {{$hookBaseName}}HookM, identifier any] interface {
Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, id ...identifier) (*gorm.DB, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) // Direct before call Database
AfterCallDb(ctx context.Context, data *obj) (*obj, error) // After database call with resultset from database
BeforeReturn(ctx context.Context, data *obj, db *gorm.DB) (*obj, error) // short before return the data
}
// Default get hook implementation
// Simple you can use and only implement the hooks you need:
// type MyGetHook struct {
// DefaultGetHook[model.Todo, int64]
// }
// func (m MyGetHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, []model.Todo, error) {
// //do some stuff
// return db, data, nil
// }
type DefaultGetHook[obj {{$hookBaseName}}HookM, identifier any] struct{}
// Direct after Resolver is call
func (d DefaultGetHook[obj, identifier]) Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, id ...identifier) (*gorm.DB, error) {
return dbHelper.Db, nil
}
// Direct before call Database
func (d DefaultGetHook[obj, identifier]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
return db, nil
}
// After database call with resultset from database
func (d DefaultGetHook[obj, identifier]) AfterCallDb(ctx context.Context, data *obj) (*obj, error) {
return data, nil
}
// short before return the data
func (d DefaultGetHook[obj, identifier]) BeforeReturn(ctx context.Context, data *obj, db *gorm.DB) (*obj, error) {
return data, nil
}
// Interface description of a query Hook
// Simple you can use DefaultQueryHook and only implement the hooks you need:
// type MyQueryHook struct {
// DefaultQueryHook[model.Todo, model.TodoFiltersInput, model.TodoOrder]
// }
// func (m MyQueryHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, []model.Todo, error) {
// //do some stuff
// return db, nil
// }
type {{$hookBaseName}}HookQuery[obj {{$hookBaseName}}HookM, filter {{$hookBaseName}}HookF, order {{$hookBaseName}}HookQueryO] interface {
Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, filter *filter, order *order, first, offset *int) (*gorm.DB, *filter, *order, *int, *int, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) // Direct before call Database
AfterCallDb(ctx context.Context, data []*obj) ([]*obj, error) // After database call with resultset from database
BeforeReturn(ctx context.Context, data []*obj, db *gorm.DB) ([]*obj, error) // short before return the data
}
// Default query hook implementation
// Simple you can use DefaultQueryHook and only implement the hooks you need:
// type MyQueryHook struct {
// DefaultQueryHook[model.Todo, model.TodoFiltersInput, model.TodoOrder]
// }
// func (m MyQueryHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, []model.Todo, error) {
// //do some stuff
// return db, nil
// }
type DefaultQueryHook[obj {{$hookBaseName}}HookM, filter {{$hookBaseName}}HookF, order {{$hookBaseName}}HookQueryO] struct{}
// Direct after Resolver is call
func (d DefaultQueryHook[obj, filterType, orderType]) Received(ctx context.Context, dbHelper *AutoGqlDB, filter *filterType, order *orderType, first, offset *int) (*gorm.DB, *filterType, *orderType, *int, *int, error) {
return dbHelper.Db, filter, order, first, offset, nil
}
// Direct before call Database
func (d DefaultQueryHook[obj, filter, order]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
return db, nil
}
// After database call with resultset from database
func (d DefaultQueryHook[obj, filter, order]) AfterCallDb(ctx context.Context, data []*obj) ([]*obj, error) {
return data, nil
}
// short before return the data
func (d DefaultQueryHook[obj, filter, order]) BeforeReturn(ctx context.Context, data []*obj, db *gorm.DB) ([]*obj, error) {
return data, nil
}
// Interface description of a add Hook
// Simple you can use DefaultAddHook and only implement the hooks you need:
// type MyAddHook struct {
// DefaultAddHook[model.Todo, model.TodoInput, model.AddTodoPayload]
// }
// func (m MyAddHook) BeforeCallDb(ctx context.Context, db *gorm.DB, data []model.Todo) (*gorm.DB, []model.Todo, error) {
// //do some stuff
// return db, data, nil
// }
type {{$hookBaseName}}HookAdd[obj {{$hookBaseName}}HookM, input {{$hookBaseName}}HookI, res {{$hookBaseName}}HookAP] interface {
Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, input []*input) (*gorm.DB, []*input, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB, data []obj) (*gorm.DB,[]obj, error) // Direct before call Database
BeforeReturn(ctx context.Context, db *gorm.DB, data []obj, res *res) (*res, error) // After database call with resultset from database
}
// Default add hook implementation
// Simple you can use DefaultAddHook and only implement the hooks you need:
// type MyAddHook struct {
// DefaultAddHook[model.Todo, model.TodoInput, model.AddTodoPayload]
// }
// func (m MyAddHook) BeforeCallDb(ctx context.Context, db *gorm.DB, data []model.Todo) (*gorm.DB, []model.Todo, error) {
// //do some stuff
// return db, data, nil
// }
type DefaultAddHook[obj {{$hookBaseName}}HookM, input {{$hookBaseName}}HookI, res {{$hookBaseName}}HookAP] struct{}
// Direct after Resolver is call
func (d DefaultAddHook[obj, inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input []*inputType) (*gorm.DB, []*inputType, error) {
return dbHelper.Db, input, nil
}
// Direct before call Database
func (d DefaultAddHook[obj, inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB, data []obj) (*gorm.DB, []obj, error) {
return db, data, nil
}
// After database call with resultset from database
func (d DefaultAddHook[obj, inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, data []obj, res *resType) (*resType, error) {
return res, nil
}
// Interface description of a update Hook
// Simple you can use DefaultUpdateHook and only implement the hooks you need:
// type MyUpdateHook struct {
// DefaultUpdateHook[model.TodoInput, model.UpdateTodoPayload]
// }
// func (m MyUpdateHook) BeforeCallDb(ctx context.Context, db *gorm.DB, data map[string]interface{}) (*gorm.DB, map[string]interface{}, error) {
// //do some stuff
// return db, data, nil
// }
type {{$hookBaseName}}HookUpdate[ input {{$hookBaseName}}HookU, res {{$hookBaseName}}HookUP]interface{
Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, input *input) (*gorm.DB, input, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB, data map[string]interface{}) (*gorm.DB, map[string]interface{}, error) // Direct before call Database
BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error) // After database call with resultset from database
}
// Default update hook implementation
// Simple you can use DefaultUpdateHook and only implement the hooks you need:
// type MyUpdateHook struct {
// DefaultUpdateHook[model.TodoInput, model.UpdateTodoPayload]
// }
// func (m MyUpdateHook) BeforeCallDb(ctx context.Context, db *gorm.DB, data map[string]interface{}) (*gorm.DB, map[string]interface{}, error) {
// //do some stuff
// return db, data, nil
// }
type DefaultUpdateHook[input {{$hookBaseName}}HookU, res {{$hookBaseName}}HookUP] struct{}
// Direct after Resolver is call
func (d DefaultUpdateHook[inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input *inputType) (*gorm.DB, inputType, error) {
return dbHelper.Db, *input, nil
}
// Direct before call Database
func (d DefaultUpdateHook[inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB, data map[string]interface{}) (*gorm.DB, map[string]interface{}, error) {
return db, data, nil
}
// After database call with resultset from database
func (d DefaultUpdateHook[inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error) {
return res, nil
}
// Interface description of a many2many Hook
// Simple you can use DefaultMany2ManyHook and only implement the hooks you need:
// type MyM2mHook struct {
// DefaultMany2ManyHook[model.UserRef2TodosInput, model.UpdateTodoPayload]
// }
// func (m MyM2mHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
// //do some stuff
// return db, nil
// }
type {{$hookBaseName}}HookMany2ManyAdd[input {{$hookBaseName}}HookM2M, res AutoGqlHookUP] interface {
Received(ctx context.Context, dbHelper *AutoGqlDB, input *input) (*gorm.DB, input, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) // Direct before call Database
BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error) // After database call with resultset from database
}
// Default many2many hook implementation
// Simple you can use DefaultMany2ManyAddHook and only implement the hooks you need:
// type MyM2mHook struct {
// DefaultMany2ManyAddHook[model.UserRef2TodosInput, model.UpdateTodoPayload]
// }
// func (m MyM2mAddHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
// //do some stuff
// return db, nil
// }
type DefaultMany2ManyAddHook[input {{$hookBaseName}}HookM2M, res {{$hookBaseName}}HookUP] struct {}
// Direct after Resolver is call
func (d DefaultMany2ManyAddHook[inputType, resType])Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, input *inputType) (*gorm.DB, inputType, error){
return dbHelper.Db, *input, nil
}
// Direct before call Database
func (d DefaultMany2ManyAddHook[inputType, resType])BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error){
return db, nil
}
// After database call with resultset from database
func (d DefaultMany2ManyAddHook[inputType, resType])BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error){
return res, nil
}
// Interface description of a many2many delete Hook
// Simple you can use DefaultMany2ManyHook and only implement the hooks you need:
// type MyM2mDeleteHook struct {
// DefaultMany2ManyDeleteHook[model.UserRef2TodosInput, model.UpdateTodoPayload]
// }
// func (m MyM2mDeleteHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
// //do some stuff
// return db, nil
// }
type {{$hookBaseName}}HookMany2ManyDelete[input {{$hookBaseName}}HookM2M, res AutoGqlHookDP] interface {
Received(ctx context.Context, dbHelper *AutoGqlDB, input *input) (*gorm.DB, input, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) // Direct before call Database
BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error) // After database call with resultset from database
}
// Default many2many delete hook implementation
// Simple you can use DefaultMany2ManyDeleteHook and only implement the hooks you need:
// type MyM2mDeleteHook struct {
// DefaultMany2ManyDeleteHook[model.UserRef2TodosInput, model.UpdateTodoPayload]
// }
// func (m MyM2mDeleteHook) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
// //do some stuff
// return db, nil
// }
type DefaultMany2ManyDeleteHook[input {{$hookBaseName}}HookM2M, res {{$hookBaseName}}HookDP] struct {}
// Direct after Resolver is call
func (d DefaultMany2ManyDeleteHook[inputType, resType])Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, input *inputType) (*gorm.DB, inputType, error){
return dbHelper.Db, *input, nil
}
// Direct before call Database
func (d DefaultMany2ManyDeleteHook[inputType, resType])BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error){
return db, nil
}
// After database call with resultset from database
func (d DefaultMany2ManyDeleteHook[inputType, resType])BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error){
return res, nil
}
// Interface description of a delete Hook
// Simple you can use DefaultDeleteHook and only implement the hooks you need:
// type MyDeleteHook struct {
// DefaultDeleteHook[model.TodoFiltersInput, model.DeleteTodoPayload]
// }
// func (m MyDeleteHook) BeforeCallDb(ctx context.Context, db *gorm.DB, input model.TodoFiltersInput) (*gorm.DB, model.TodoFiltersInput, error) {
// //do some stuff
// return db, input, nil
// }
type {{$hookBaseName}}HookDelete[input {{$hookBaseName}}HookF, res {{$hookBaseName}}HookDP] interface {
Received(ctx context.Context, dbHelper *{{$hookBaseName}}DB, input *input) (*gorm.DB, input, error) // Direct after Resolver is call
BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) // Direct before call Database
BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error) // After database call with resultset from database
}
// Default delete hook implementation
// Simple you can use DefaultDeleteHook and only implement the hooks you need:
// type MyM2mHook struct {
// DefaultDeleteHook[model.TodoFiltersInput, model.DeleteTodoPayload]
// }
// func (m MyM2mHook) BeforeCallDb(ctx context.Context, db *gorm.DB, input model.TodoFiltersInput) (*gorm.DB, model.TodoFiltersInput, error) {
// //do some stuff
// return db, input, nil
// }
type DefaultDeleteHook[input {{$hookBaseName}}HookF, res {{$hookBaseName}}HookDP] struct{}
// Direct after Resolver is call
func (d DefaultDeleteHook[inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input *inputType) (*gorm.DB, inputType, error) {
return dbHelper.Db, *input, nil
}
// Direct before call Database
func (d DefaultDeleteHook[inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error) {
return db, nil
}
// After database call with resultset from database
func (d DefaultDeleteHook[inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error) {
return res, nil
}