forked from sensu/sensu-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.gql.go
377 lines (351 loc) · 12.6 KB
/
errors.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
// 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"
)
/*
ErrorType Error describes a failed pre-condition or unexpected problem that occurred while
processing the operation.
*/
var ErrorType = graphql.NewType("Error", graphql.InterfaceKind)
// RegisterError registers Error object type with given service.
func RegisterError(svc *graphql.Service, impl graphql.InterfaceTypeResolver) {
svc.RegisterInterface(_InterfaceTypeErrorDesc, impl)
}
func _InterfaceTypeErrorConfigFn() graphql1.InterfaceConfig {
return graphql1.InterfaceConfig{
Description: "Error describes a failed pre-condition or unexpected problem that occurred while\nprocessing the operation.",
Fields: graphql1.Fields{
"code": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "A code concisely describing the error.",
Name: "code",
Type: graphql1.NewNonNull(graphql.OutputType("ErrCode")),
},
"input": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "The field associated with the error.",
Name: "input",
Type: graphql1.String,
},
},
Name: "Error",
ResolveType: func(_ graphql1.ResolveTypeParams) *graphql1.Object {
// 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 InterfaceTypeResolver.")
},
}
}
// describe Error's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _InterfaceTypeErrorDesc = graphql.InterfaceDesc{Config: _InterfaceTypeErrorConfigFn}
// StandardErrorInputFieldResolver implement to resolve requests for the StandardError's input field.
type StandardErrorInputFieldResolver interface {
// Input implements response to request for input field.
Input(p graphql.ResolveParams) (string, error)
}
// StandardErrorCodeFieldResolver implement to resolve requests for the StandardError's code field.
type StandardErrorCodeFieldResolver interface {
// Code implements response to request for code field.
Code(p graphql.ResolveParams) (ErrCode, error)
}
// StandardErrorMessageFieldResolver implement to resolve requests for the StandardError's message field.
type StandardErrorMessageFieldResolver interface {
// Message implements response to request for message field.
Message(p graphql.ResolveParams) (string, error)
}
//
// StandardErrorFieldResolvers represents a collection of methods whose products represent the
// response values of the 'StandardError' 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 StandardErrorFieldResolvers interface {
StandardErrorInputFieldResolver
StandardErrorCodeFieldResolver
StandardErrorMessageFieldResolver
}
// StandardErrorAliases implements all methods on StandardErrorFieldResolvers 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 StandardErrorAliases struct{}
// Input implements response to request for 'input' field.
func (_ StandardErrorAliases) Input(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 'input'")
}
return ret, err
}
// Code implements response to request for 'code' field.
func (_ StandardErrorAliases) Code(p graphql.ResolveParams) (ErrCode, error) {
val, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)
ret, ok := ErrCode(val.(string)), true
if err != nil {
return ret, err
}
if !ok {
return ret, errors.New("unable to coerce value for field 'code'")
}
return ret, err
}
// Message implements response to request for 'message' field.
func (_ StandardErrorAliases) Message(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 'message'")
}
return ret, err
}
/*
StandardErrorType StandardError is the standard implementation of an error that includes a
message.
*/
var StandardErrorType = graphql.NewType("StandardError", graphql.ObjectKind)
// RegisterStandardError registers StandardError object type with given service.
func RegisterStandardError(svc *graphql.Service, impl StandardErrorFieldResolvers) {
svc.RegisterObject(_ObjectTypeStandardErrorDesc, impl)
}
func _ObjTypeStandardErrorInputHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(StandardErrorInputFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Input(frp)
}
}
func _ObjTypeStandardErrorCodeHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(StandardErrorCodeFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
val, err := resolver.Code(frp)
return string(val), err
}
}
func _ObjTypeStandardErrorMessageHandler(impl interface{}) graphql1.FieldResolveFn {
resolver := impl.(StandardErrorMessageFieldResolver)
return func(frp graphql1.ResolveParams) (interface{}, error) {
return resolver.Message(frp)
}
}
func _ObjectTypeStandardErrorConfigFn() graphql1.ObjectConfig {
return graphql1.ObjectConfig{
Description: "StandardError is the standard implementation of an error that includes a\nmessage.",
Fields: graphql1.Fields{
"code": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "A code concisely describing the error.",
Name: "code",
Type: graphql1.NewNonNull(graphql.OutputType("ErrCode")),
},
"input": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "The field associated with the error.",
Name: "input",
Type: graphql1.String,
},
"message": &graphql1.Field{
Args: graphql1.FieldConfigArgument{},
DeprecationReason: "",
Description: "Message describing the error.",
Name: "message",
Type: graphql1.NewNonNull(graphql1.String),
},
},
Interfaces: []*graphql1.Interface{
graphql.Interface("Error")},
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 StandardErrorFieldResolvers.")
},
Name: "StandardError",
}
}
// describe StandardError's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _ObjectTypeStandardErrorDesc = graphql.ObjectDesc{
Config: _ObjectTypeStandardErrorConfigFn,
FieldHandlers: map[string]graphql.FieldHandler{
"code": _ObjTypeStandardErrorCodeHandler,
"input": _ObjTypeStandardErrorInputHandler,
"message": _ObjTypeStandardErrorMessageHandler,
},
}
// ErrCode A terse description of an error.
type ErrCode string
// ErrCodes holds enum values
var ErrCodes = _EnumTypeErrCodeValues{
ERR_ALREADY_EXISTS: "ERR_ALREADY_EXISTS",
ERR_INTERNAL: "ERR_INTERNAL",
ERR_NOT_FOUND: "ERR_NOT_FOUND",
ERR_PERMISSION_DENIED: "ERR_PERMISSION_DENIED",
}
// ErrCodeType A terse description of an error.
var ErrCodeType = graphql.NewType("ErrCode", graphql.EnumKind)
// RegisterErrCode registers ErrCode object type with given service.
func RegisterErrCode(svc *graphql.Service) {
svc.RegisterEnum(_EnumTypeErrCodeDesc)
}
func _EnumTypeErrCodeConfigFn() graphql1.EnumConfig {
return graphql1.EnumConfig{
Description: "A terse description of an error.",
Name: "ErrCode",
Values: graphql1.EnumValueConfigMap{
"ERR_ALREADY_EXISTS": &graphql1.EnumValueConfig{
DeprecationReason: "",
Description: "Indicates that a record already exists and the operation could not be\ncompleted.",
Value: "ERR_ALREADY_EXISTS",
},
"ERR_INTERNAL": &graphql1.EnumValueConfig{
DeprecationReason: "",
Description: "Indicates that some unrecoverable error occurred during execution of the\noperation.",
Value: "ERR_INTERNAL",
},
"ERR_NOT_FOUND": &graphql1.EnumValueConfig{
DeprecationReason: "",
Description: "Indicates that the record associated with the given field could not be found.",
Value: "ERR_NOT_FOUND",
},
"ERR_PERMISSION_DENIED": &graphql1.EnumValueConfig{
DeprecationReason: "",
Description: "Operation was canceled because the authorization token did not have sufficient\npermissions.",
Value: "ERR_PERMISSION_DENIED",
},
},
}
}
// describe ErrCode's configuration; kept private to avoid unintentional tampering of configuration at runtime.
var _EnumTypeErrCodeDesc = graphql.EnumDesc{Config: _EnumTypeErrCodeConfigFn}
type _EnumTypeErrCodeValues struct {
/*
ERR_INTERNAL - Indicates that some unrecoverable error occurred during execution of the
operation.
*/
ERR_INTERNAL ErrCode
// ERR_NOT_FOUND - Indicates that the record associated with the given field could not be found.
ERR_NOT_FOUND ErrCode
/*
ERR_ALREADY_EXISTS - Indicates that a record already exists and the operation could not be
completed.
*/
ERR_ALREADY_EXISTS ErrCode
/*
ERR_PERMISSION_DENIED - Operation was canceled because the authorization token did not have sufficient
permissions.
*/
ERR_PERMISSION_DENIED ErrCode
}