forked from sensu/sensu-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.gql.go
983 lines (918 loc) · 31.8 KB
/
hook.gql.go
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
// Code generated by scripts/gengraphql.go. DO NOT EDIT.
package schema
import (
errors "errors"
graphql1 "github.com/graphql-go/graphql"
graphql "github.com/sensu/sensu-go/graphql"
)
// HookConfigIDFieldResolver implement to resolve requests for the HookConfig's id field.
type HookConfigIDFieldResolver interface {
// ID implements response to request for id field.
ID(p graphql.ResolveParams) (string, error)
}
// HookConfigNamespaceFieldResolver implement to resolve requests for the HookConfig's namespace field.
type HookConfigNamespaceFieldResolver interface {
// Namespace implements response to request for namespace field.
Namespace(p graphql.ResolveParams) (string, error)
}
// HookConfigNameFieldResolver implement to resolve requests for the HookConfig's name field.
type HookConfigNameFieldResolver interface {
// Name implements response to request for name field.
Name(p graphql.ResolveParams) (string, error)
}
// HookConfigMetadataFieldResolver implement to resolve requests for the HookConfig's metadata field.
type HookConfigMetadataFieldResolver interface {
// Metadata implements response to request for metadata field.
Metadata(p graphql.ResolveParams) (interface{}, error)
}
// HookConfigCommandFieldResolver implement to resolve requests for the HookConfig's command field.
type HookConfigCommandFieldResolver interface {
// Command implements response to request for command field.
Command(p graphql.ResolveParams) (string, error)
}
// HookConfigTimeoutFieldResolver implement to resolve requests for the HookConfig's timeout field.
type HookConfigTimeoutFieldResolver interface {
// Timeout implements response to request for timeout field.
Timeout(p graphql.ResolveParams) (int, error)
}
// HookConfigStdinFieldResolver implement to resolve requests for the HookConfig's stdin field.
type HookConfigStdinFieldResolver interface {
// Stdin implements response to request for stdin field.
Stdin(p graphql.ResolveParams) (bool, error)
}
// HookConfigToJSONFieldResolver implement to resolve requests for the HookConfig's toJSON field.
type HookConfigToJSONFieldResolver interface {
// ToJSON implements response to request for toJSON field.
ToJSON(p graphql.ResolveParams) (interface{}, error)
}
//
// HookConfigFieldResolvers represents a collection of methods whose products represent the
// response values of the 'HookConfig' type.
//
// == Example SDL
//
// """
// Dog's are not hooman.
// """
// type Dog implements Pet {
// "name of this fine beast."
// name: String!
//
// "breed of this silly animal; probably shibe."
// breed: [Breed]
// }
//
// == Example generated interface
//
// // DogResolver ...
// type DogFieldResolvers interface {
// DogNameFieldResolver
// DogBreedFieldResolver
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// IsTypeOf(interface{}, graphql.IsTypeOfParams) bool
// }
//
// == Example implementation ...
//
// // DogResolver implements DogFieldResolvers interface
// type DogResolver struct {
// logger logrus.LogEntry
// store interface{
// store.BreedStore
// store.DogStore
// }
// }
//
// // Name implements response to request for name field.
// func (r *DogResolver) Name(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// return dog.GetName()
// }
//
// // Breed implements response to request for breed field.
// func (r *DogResolver) Breed(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// breed := r.store.GetBreed(dog.GetBreedName())
// return breed
// }
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// func (r *DogResolver) IsTypeOf(p graphql.IsTypeOfParams) bool {
// // ... implementation details ...
// _, ok := p.Value.(DogGetter)
// return ok
// }
//
type HookConfigFieldResolvers interface {
HookConfigIDFieldResolver
HookConfigNamespaceFieldResolver
HookConfigNameFieldResolver
HookConfigMetadataFieldResolver
HookConfigCommandFieldResolver
HookConfigTimeoutFieldResolver
HookConfigStdinFieldResolver
HookConfigToJSONFieldResolver
}
// HookConfigAliases implements all methods on HookConfigFieldResolvers interface by using reflection to
// match name of field to a field on the given value. Intent is reduce friction
// of writing new resolvers by removing all the instances where you would simply
// have the resolvers method return a field.
//
// == Example SDL
//
// type Dog {
// name: String!
// weight: Float!
// dob: DateTime
// breed: [Breed]
// }
//
// == Example generated aliases
//
// type DogAliases struct {}
// func (_ DogAliases) Name(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Weight(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Dob(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Breed(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
//
// == Example Implementation
//
// type DogResolver struct { // Implements DogResolver
// DogAliases
// store store.BreedStore
// }
//
// // NOTE:
// // All other fields are satisified by DogAliases but since this one
// // requires hitting the store we implement it in our resolver.
// func (r *DogResolver) Breed(p graphql.ResolveParams) interface{} {
// dog := v.(*Dog)
// return r.BreedsById(dog.BreedIDs)
// }
//
type HookConfigAliases struct{}
// ID implements response to request for 'id' field.
func (_ HookConfigAliases) ID(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'id'")
}
return ret, err
}
// Namespace implements response to request for 'namespace' field.
func (_ HookConfigAliases) Namespace(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'namespace'")
}
return ret, err
}
// Name implements response to request for 'name' field.
func (_ HookConfigAliases) Name(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'name'")
}
return ret, err
}
// Metadata implements response to request for 'metadata' field.
func (_ HookConfigAliases) Metadata(p graphql.ResolveParams) (interface{}, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
return val, err
}
// Command implements response to request for 'command' field.
func (_ HookConfigAliases) Command(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'command'")
}
return ret, err
}
// Timeout implements response to request for 'timeout' field.
func (_ HookConfigAliases) Timeout(p graphql.ResolveParams) (int, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := graphql1.Int.ParseValue(val).(int)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'timeout'")
}
return ret, err
}
// Stdin implements response to request for 'stdin' field.
func (_ HookConfigAliases) Stdin(p graphql.ResolveParams) (bool, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(bool)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'stdin'")
}
return ret, err
}
// ToJSON implements response to request for 'toJSON' field.
func (_ HookConfigAliases) ToJSON(p graphql.ResolveParams) (interface{}, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
return val, err
}
// HookConfigType HookConfig is the specification of a hook
var HookConfigType = graphql.NewType("HookConfig", graphql.ObjectKind)
// RegisterHookConfig registers HookConfig object type with given service.
func RegisterHookConfig(svc *graphql.Service, impl HookConfigFieldResolvers) {
svc.RegisterObject(_ObjectTypeHookConfigDesc, impl)
}
func _ObjTypeHookConfigIDHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigIDFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.ID(frp)
}
}
func _ObjTypeHookConfigNamespaceHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigNamespaceFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Namespace(frp)
}
}
func _ObjTypeHookConfigNameHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigNameFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Name(frp)
}
}
func _ObjTypeHookConfigMetadataHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigMetadataFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Metadata(frp)
}
}
func _ObjTypeHookConfigCommandHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigCommandFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Command(frp)
}
}
func _ObjTypeHookConfigTimeoutHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigTimeoutFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Timeout(frp)
}
}
func _ObjTypeHookConfigStdinHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigStdinFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Stdin(frp)
}
}
func _ObjTypeHookConfigToJSONHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigToJSONFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.ToJSON(frp)
}
}
func _ObjectTypeHookConfigConfigFn() graphql1.ObjectConfig {
return graphql1.ObjectConfig{
Description: "HookConfig is the specification of a hook",
Fields: graphql1.Fields{
"command": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Command is the command to be executed",
Name: "command",
Type: graphql1.String,
},
"id": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "The globally unique identifier of the record",
Name: "id",
Type: graphql1.NewNonNull(graphql1.ID),
},
"metadata": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "metadata contains name, namespace, labels and annotations of the record",
Name: "metadata",
Type: graphql1.NewNonNull(graphql.OutputType("ObjectMeta")),
},
"name": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Name is the unique identifier for a hook",
Name: "name",
Type: graphql1.NewNonNull(graphql1.String),
},
"namespace": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Namespace in which this record resides",
Name: "namespace",
Type: graphql1.NewNonNull(graphql1.String),
},
"stdin": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Stdin indicates if hook requests have stdin enabled",
Name: "stdin",
Type: graphql1.NewNonNull(graphql1.Boolean),
},
"timeout": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Timeout is the timeout, in seconds, at which the hook has to run",
Name: "timeout",
Type: graphql1.Int,
},
"toJSON": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "toJSON returns a REST API compatible representation of the resource. Handy for\nsharing snippets that can then be imported with `sensuctl create`.",
Name: "toJSON",
Type: graphql1.NewNonNull(graphql.OutputType("JSON")),
},
},
Interfaces: []*graphql1.Interface{
graphql.Interface("Node"),
graphql.Interface("Namespaced"),
graphql.Interface("Resource")},
IsTypeOf: func(_ graphql1.IsTypeOfParams) bool {
// NOTE:
// Panic by default. Intent is that when Service is invoked, values of
// these fields are updated with instantiated resolvers. If these
// defaults are called it is most certainly programmer err.
// If you're see this comment then: 'Whoops! Sorry, my bad.'
panic("Unimplemented; see HookConfigFieldResolvers.")
},
Name: "HookConfig",
}
}
// describe HookConfig's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _ObjectTypeHookConfigDesc = graphql.ObjectDesc{
Config: _ObjectTypeHookConfigConfigFn,
FieldHandlers: map[string]graphql.FieldHandler{
"command": _ObjTypeHookConfigCommandHandler,
"id": _ObjTypeHookConfigIDHandler,
"metadata": _ObjTypeHookConfigMetadataHandler,
"name": _ObjTypeHookConfigNameHandler,
"namespace": _ObjTypeHookConfigNamespaceHandler,
"stdin": _ObjTypeHookConfigStdinHandler,
"timeout": _ObjTypeHookConfigTimeoutHandler,
"toJSON": _ObjTypeHookConfigToJSONHandler,
},
}
// HookConfigFieldResolver implement to resolve requests for the Hook's config field.
type HookConfigFieldResolver interface {
// Config implements response to request for config field.
Config(p graphql.ResolveParams) (interface{}, error)
}
// HookDurationFieldResolver implement to resolve requests for the Hook's duration field.
type HookDurationFieldResolver interface {
// Duration implements response to request for duration field.
Duration(p graphql.ResolveParams) (int, error)
}
// HookExecutedFieldResolver implement to resolve requests for the Hook's executed field.
type HookExecutedFieldResolver interface {
// Executed implements response to request for executed field.
Executed(p graphql.ResolveParams) (int, error)
}
// HookIssuedFieldResolver implement to resolve requests for the Hook's issued field.
type HookIssuedFieldResolver interface {
// Issued implements response to request for issued field.
Issued(p graphql.ResolveParams) (int, error)
}
// HookOutputFieldResolver implement to resolve requests for the Hook's output field.
type HookOutputFieldResolver interface {
// Output implements response to request for output field.
Output(p graphql.ResolveParams) (string, error)
}
// HookStatusFieldResolver implement to resolve requests for the Hook's status field.
type HookStatusFieldResolver interface {
// Status implements response to request for status field.
Status(p graphql.ResolveParams) (int, error)
}
//
// HookFieldResolvers represents a collection of methods whose products represent the
// response values of the 'Hook' type.
//
// == Example SDL
//
// """
// Dog's are not hooman.
// """
// type Dog implements Pet {
// "name of this fine beast."
// name: String!
//
// "breed of this silly animal; probably shibe."
// breed: [Breed]
// }
//
// == Example generated interface
//
// // DogResolver ...
// type DogFieldResolvers interface {
// DogNameFieldResolver
// DogBreedFieldResolver
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// IsTypeOf(interface{}, graphql.IsTypeOfParams) bool
// }
//
// == Example implementation ...
//
// // DogResolver implements DogFieldResolvers interface
// type DogResolver struct {
// logger logrus.LogEntry
// store interface{
// store.BreedStore
// store.DogStore
// }
// }
//
// // Name implements response to request for name field.
// func (r *DogResolver) Name(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// return dog.GetName()
// }
//
// // Breed implements response to request for breed field.
// func (r *DogResolver) Breed(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// breed := r.store.GetBreed(dog.GetBreedName())
// return breed
// }
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// func (r *DogResolver) IsTypeOf(p graphql.IsTypeOfParams) bool {
// // ... implementation details ...
// _, ok := p.Value.(DogGetter)
// return ok
// }
//
type HookFieldResolvers interface {
HookConfigFieldResolver
HookDurationFieldResolver
HookExecutedFieldResolver
HookIssuedFieldResolver
HookOutputFieldResolver
HookStatusFieldResolver
}
// HookAliases implements all methods on HookFieldResolvers interface by using reflection to
// match name of field to a field on the given value. Intent is reduce friction
// of writing new resolvers by removing all the instances where you would simply
// have the resolvers method return a field.
//
// == Example SDL
//
// type Dog {
// name: String!
// weight: Float!
// dob: DateTime
// breed: [Breed]
// }
//
// == Example generated aliases
//
// type DogAliases struct {}
// func (_ DogAliases) Name(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Weight(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Dob(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Breed(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
//
// == Example Implementation
//
// type DogResolver struct { // Implements DogResolver
// DogAliases
// store store.BreedStore
// }
//
// // NOTE:
// // All other fields are satisified by DogAliases but since this one
// // requires hitting the store we implement it in our resolver.
// func (r *DogResolver) Breed(p graphql.ResolveParams) interface{} {
// dog := v.(*Dog)
// return r.BreedsById(dog.BreedIDs)
// }
//
type HookAliases struct{}
// Config implements response to request for 'config' field.
func (_ HookAliases) Config(p graphql.ResolveParams) (interface{}, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
return val, err
}
// Duration implements response to request for 'duration' field.
func (_ HookAliases) Duration(p graphql.ResolveParams) (int, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := graphql1.Int.ParseValue(val).(int)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'duration'")
}
return ret, err
}
// Executed implements response to request for 'executed' field.
func (_ HookAliases) Executed(p graphql.ResolveParams) (int, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := graphql1.Int.ParseValue(val).(int)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'executed'")
}
return ret, err
}
// Issued implements response to request for 'issued' field.
func (_ HookAliases) Issued(p graphql.ResolveParams) (int, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := graphql1.Int.ParseValue(val).(int)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'issued'")
}
return ret, err
}
// Output implements response to request for 'output' field.
func (_ HookAliases) Output(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'output'")
}
return ret, err
}
// Status implements response to request for 'status' field.
func (_ HookAliases) Status(p graphql.ResolveParams) (int, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := graphql1.Int.ParseValue(val).(int)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'status'")
}
return ret, err
}
/*
HookType A Hook is a hook specification and optionally the results of the hook's
execution.
*/
var HookType = graphql.NewType("Hook", graphql.ObjectKind)
// RegisterHook registers Hook object type with given service.
func RegisterHook(svc *graphql.Service, impl HookFieldResolvers) {
svc.RegisterObject(_ObjectTypeHookDesc, impl)
}
func _ObjTypeHookConfigHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookConfigFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Config(frp)
}
}
func _ObjTypeHookDurationHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookDurationFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Duration(frp)
}
}
func _ObjTypeHookExecutedHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookExecutedFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Executed(frp)
}
}
func _ObjTypeHookIssuedHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookIssuedFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Issued(frp)
}
}
func _ObjTypeHookOutputHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookOutputFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Output(frp)
}
}
func _ObjTypeHookStatusHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookStatusFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Status(frp)
}
}
func _ObjectTypeHookConfigFn() graphql1.ObjectConfig {
return graphql1.ObjectConfig{
Description: "A Hook is a hook specification and optionally the results of the hook's\nexecution.",
Fields: graphql1.Fields{
"config": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Config is the specification of a hook",
Name: "config",
Type: graphql.OutputType("HookConfig"),
},
"duration": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Duration of execution",
Name: "duration",
Type: graphql1.Int,
},
"executed": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Executed describes the time in which the hook request was executed",
Name: "executed",
Type: graphql1.Int,
},
"issued": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Issued describes the time in which the hook request was issued",
Name: "issued",
Type: graphql1.Int,
},
"output": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Output from the execution of Command",
Name: "output",
Type: graphql1.String,
},
"status": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Status is the exit status code produced by the hook",
Name: "status",
Type: graphql1.Int,
},
},
Interfaces: []*graphql1.Interface{},
IsTypeOf: func(_ graphql1.IsTypeOfParams) bool {
// NOTE:
// Panic by default. Intent is that when Service is invoked, values of
// these fields are updated with instantiated resolvers. If these
// defaults are called it is most certainly programmer err.
// If you're see this comment then: 'Whoops! Sorry, my bad.'
panic("Unimplemented; see HookFieldResolvers.")
},
Name: "Hook",
}
}
// describe Hook's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _ObjectTypeHookDesc = graphql.ObjectDesc{
Config: _ObjectTypeHookConfigFn,
FieldHandlers: map[string]graphql.FieldHandler{
"config": _ObjTypeHookConfigHandler,
"duration": _ObjTypeHookDurationHandler,
"executed": _ObjTypeHookExecutedHandler,
"issued": _ObjTypeHookIssuedHandler,
"output": _ObjTypeHookOutputHandler,
"status": _ObjTypeHookStatusHandler,
},
}
// HookListHooksFieldResolver implement to resolve requests for the HookList's hooks field.
type HookListHooksFieldResolver interface {
// Hooks implements response to request for hooks field.
Hooks(p graphql.ResolveParams) ([]string, error)
}
// HookListTypeFieldResolver implement to resolve requests for the HookList's type field.
type HookListTypeFieldResolver interface {
// Type implements response to request for type field.
Type(p graphql.ResolveParams) (string, error)
}
//
// HookListFieldResolvers represents a collection of methods whose products represent the
// response values of the 'HookList' type.
//
// == Example SDL
//
// """
// Dog's are not hooman.
// """
// type Dog implements Pet {
// "name of this fine beast."
// name: String!
//
// "breed of this silly animal; probably shibe."
// breed: [Breed]
// }
//
// == Example generated interface
//
// // DogResolver ...
// type DogFieldResolvers interface {
// DogNameFieldResolver
// DogBreedFieldResolver
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// IsTypeOf(interface{}, graphql.IsTypeOfParams) bool
// }
//
// == Example implementation ...
//
// // DogResolver implements DogFieldResolvers interface
// type DogResolver struct {
// logger logrus.LogEntry
// store interface{
// store.BreedStore
// store.DogStore
// }
// }
//
// // Name implements response to request for name field.
// func (r *DogResolver) Name(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// return dog.GetName()
// }
//
// // Breed implements response to request for breed field.
// func (r *DogResolver) Breed(p graphql.ResolveParams) (interface{}, error) {
// // ... implementation details ...
// dog := p.Source.(DogGetter)
// breed := r.store.GetBreed(dog.GetBreedName())
// return breed
// }
//
// // IsTypeOf is used to determine if a given value is associated with the Dog type
// func (r *DogResolver) IsTypeOf(p graphql.IsTypeOfParams) bool {
// // ... implementation details ...
// _, ok := p.Value.(DogGetter)
// return ok
// }
//
type HookListFieldResolvers interface {
HookListHooksFieldResolver
HookListTypeFieldResolver
}
// HookListAliases implements all methods on HookListFieldResolvers interface by using reflection to
// match name of field to a field on the given value. Intent is reduce friction
// of writing new resolvers by removing all the instances where you would simply
// have the resolvers method return a field.
//
// == Example SDL
//
// type Dog {
// name: String!
// weight: Float!
// dob: DateTime
// breed: [Breed]
// }
//
// == Example generated aliases
//
// type DogAliases struct {}
// func (_ DogAliases) Name(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Weight(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Dob(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
// func (_ DogAliases) Breed(p graphql.ResolveParams) (interface{}, error) {
// // reflect...
// }
//
// == Example Implementation
//
// type DogResolver struct { // Implements DogResolver
// DogAliases
// store store.BreedStore
// }
//
// // NOTE:
// // All other fields are satisified by DogAliases but since this one
// // requires hitting the store we implement it in our resolver.
// func (r *DogResolver) Breed(p graphql.ResolveParams) interface{} {
// dog := v.(*Dog)
// return r.BreedsById(dog.BreedIDs)
// }
//
type HookListAliases struct{}
// Hooks implements response to request for 'hooks' field.
func (_ HookListAliases) Hooks(p graphql.ResolveParams) ([]string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.([]string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'hooks'")
}
return ret, err
}
// Type implements response to request for 'type' field.
func (_ HookListAliases) Type(p graphql.ResolveParams) (string, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := val.(string)
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'type'")
}
return ret, err
}
// HookListType self descriptive
var HookListType = graphql.NewType("HookList", graphql.ObjectKind)
// RegisterHookList registers HookList object type with given service.
func RegisterHookList(svc *graphql.Service, impl HookListFieldResolvers) {
svc.RegisterObject(_ObjectTypeHookListDesc, impl)
}
func _ObjTypeHookListHooksHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookListHooksFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Hooks(frp)
}
}
func _ObjTypeHookListTypeHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(HookListTypeFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Type(frp)
}
}
func _ObjectTypeHookListConfigFn() graphql1.ObjectConfig {
return graphql1.ObjectConfig{
Description: "self descriptive",
Fields: graphql1.Fields{
"hooks": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Hooks is the list of hooks for the check hook",
Name: "hooks",
Type: graphql1.NewNonNull(graphql1.NewList(graphql1.NewNonNull(graphql1.String))),
},
"type": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Type indicates the type or response code for the check hook",
Name: "type",
Type: graphql1.NewNonNull(graphql1.String),
},
},
Interfaces: []*graphql1.Interface{},
IsTypeOf: func(_ graphql1.IsTypeOfParams) bool {
// NOTE:
// Panic by default. Intent is that when Service is invoked, values of
// these fields are updated with instantiated resolvers. If these
// defaults are called it is most certainly programmer err.
// If you're see this comment then: 'Whoops! Sorry, my bad.'
panic("Unimplemented; see HookListFieldResolvers.")
},
Name: "HookList",
}
}
// describe HookList's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _ObjectTypeHookListDesc = graphql.ObjectDesc{
Config: _ObjectTypeHookListConfigFn,
FieldHandlers: map[string]graphql.FieldHandler{
"hooks": _ObjTypeHookListHooksHandler,
"type": _ObjTypeHookListTypeHandler,
},
}