@@ -19,23 +19,44 @@ const (
19
19
TypeKindNonNull = "NON_NULL"
20
20
)
21
21
22
- var directiveType * Object
23
- var schemaType * Object
24
- var typeType * Object
25
- var fieldType * Object
26
- var inputValueType * Object
27
- var enumValueType * Object
22
+ // SchemaType is type definition for __Schema
23
+ var SchemaType * Object
28
24
29
- var typeKindEnum * Enum
30
- var directiveLocationEnum * Enum
25
+ // DirectiveType is type definition for __Directive
26
+ var DirectiveType * Object
31
27
28
+ // TypeType is type definition for __Type
29
+ var TypeType * Object
30
+
31
+ // FieldType is type definition for __Field
32
+ var FieldType * Object
33
+
34
+ // InputValueType is type definition for __InputValue
35
+ var InputValueType * Object
36
+
37
+ // EnumValueType is type definition for __EnumValue
38
+ var EnumValueType * Object
39
+
40
+ // TypeKindEnumType is type definition for __TypeKind
41
+ var TypeKindEnumType * Enum
42
+
43
+ // DirectiveLocationEnumType is type definition for __DirectiveLocation
44
+ var DirectiveLocationEnumType * Enum
45
+
46
+ // Meta-field definitions.
47
+
48
+ // SchemaMetaFieldDef Meta field definition for Schema
32
49
var SchemaMetaFieldDef * FieldDefinition
50
+
51
+ // TypeMetaFieldDef Meta field definition for types
33
52
var TypeMetaFieldDef * FieldDefinition
53
+
54
+ // TypeNameMetaFieldDef Meta field definition for type names
34
55
var TypeNameMetaFieldDef * FieldDefinition
35
56
36
57
func init () {
37
58
38
- typeKindEnum = NewEnum (EnumConfig {
59
+ TypeKindEnumType = NewEnum (EnumConfig {
39
60
Name : "__TypeKind" ,
40
61
Description : "An enum describing what kind of type a given `__Type` is" ,
41
62
Values : EnumValueConfigMap {
@@ -81,7 +102,7 @@ func init() {
81
102
},
82
103
})
83
104
84
- directiveLocationEnum = NewEnum (EnumConfig {
105
+ DirectiveLocationEnumType = NewEnum (EnumConfig {
85
106
Name : "__DirectiveLocation" ,
86
107
Description : "A Directive can be adjacent to many parts of the GraphQL language, a " +
87
108
"__DirectiveLocation describes one such possible adjacencies." ,
@@ -118,7 +139,7 @@ func init() {
118
139
})
119
140
120
141
// Note: some fields (for e.g "fields", "interfaces") are defined later due to cyclic reference
121
- typeType = NewObject (ObjectConfig {
142
+ TypeType = NewObject (ObjectConfig {
122
143
Name : "__Type" ,
123
144
Description : "The fundamental unit of any GraphQL Schema is the type. There are " +
124
145
"many kinds of types in GraphQL as represented by the `__TypeKind` enum." +
@@ -131,7 +152,7 @@ func init() {
131
152
132
153
Fields : Fields {
133
154
"kind" : & Field {
134
- Type : NewNonNull (typeKindEnum ),
155
+ Type : NewNonNull (TypeKindEnumType ),
135
156
Resolve : func (p ResolveParams ) (interface {}, error ) {
136
157
switch p .Source .(type ) {
137
158
case * Scalar :
@@ -169,7 +190,7 @@ func init() {
169
190
},
170
191
})
171
192
172
- inputValueType = NewObject (ObjectConfig {
193
+ InputValueType = NewObject (ObjectConfig {
173
194
Name : "__InputValue" ,
174
195
Description : "Arguments provided to Fields or Directives and the input fields of an " +
175
196
"InputObject are represented as Input Values which describe their type " +
@@ -182,7 +203,7 @@ func init() {
182
203
Type : String ,
183
204
},
184
205
"type" : & Field {
185
- Type : NewNonNull (typeType ),
206
+ Type : NewNonNull (TypeType ),
186
207
},
187
208
"defaultValue" : & Field {
188
209
Type : String ,
@@ -212,7 +233,7 @@ func init() {
212
233
},
213
234
})
214
235
215
- fieldType = NewObject (ObjectConfig {
236
+ FieldType = NewObject (ObjectConfig {
216
237
Name : "__Field" ,
217
238
Description : "Object and Interface types are described by a list of Fields, each of " +
218
239
"which has a name, potentially a list of arguments, and a return type." ,
@@ -224,7 +245,7 @@ func init() {
224
245
Type : String ,
225
246
},
226
247
"args" : & Field {
227
- Type : NewNonNull (NewList (NewNonNull (inputValueType ))),
248
+ Type : NewNonNull (NewList (NewNonNull (InputValueType ))),
228
249
Resolve : func (p ResolveParams ) (interface {}, error ) {
229
250
if field , ok := p .Source .(* FieldDefinition ); ok {
230
251
return field .Args , nil
@@ -233,7 +254,7 @@ func init() {
233
254
},
234
255
},
235
256
"type" : & Field {
236
- Type : NewNonNull (typeType ),
257
+ Type : NewNonNull (TypeType ),
237
258
},
238
259
"isDeprecated" : & Field {
239
260
Type : NewNonNull (Boolean ),
@@ -250,7 +271,7 @@ func init() {
250
271
},
251
272
})
252
273
253
- directiveType = NewObject (ObjectConfig {
274
+ DirectiveType = NewObject (ObjectConfig {
254
275
Name : "__Directive" ,
255
276
Description : "A Directive provides a way to describe alternate runtime execution and " +
256
277
"type validation behavior in a GraphQL document. " +
@@ -267,12 +288,12 @@ func init() {
267
288
},
268
289
"locations" : & Field {
269
290
Type : NewNonNull (NewList (
270
- NewNonNull (directiveLocationEnum ),
291
+ NewNonNull (DirectiveLocationEnumType ),
271
292
)),
272
293
},
273
294
"args" : & Field {
274
295
Type : NewNonNull (NewList (
275
- NewNonNull (inputValueType ),
296
+ NewNonNull (InputValueType ),
276
297
)),
277
298
},
278
299
// NOTE: the following three fields are deprecated and are no longer part
@@ -335,7 +356,7 @@ func init() {
335
356
},
336
357
})
337
358
338
- schemaType = NewObject (ObjectConfig {
359
+ SchemaType = NewObject (ObjectConfig {
339
360
Name : "__Schema" ,
340
361
Description : `A GraphQL Schema defines the capabilities of a GraphQL server. ` +
341
362
`It exposes all available types and directives on the server, as well as ` +
@@ -344,7 +365,7 @@ func init() {
344
365
"types" : & Field {
345
366
Description : "A list of all types supported by this server." ,
346
367
Type : NewNonNull (NewList (
347
- NewNonNull (typeType ),
368
+ NewNonNull (TypeType ),
348
369
)),
349
370
Resolve : func (p ResolveParams ) (interface {}, error ) {
350
371
if schema , ok := p .Source .(Schema ); ok {
@@ -359,7 +380,7 @@ func init() {
359
380
},
360
381
"queryType" : & Field {
361
382
Description : "The type that query operations will be rooted at." ,
362
- Type : NewNonNull (typeType ),
383
+ Type : NewNonNull (TypeType ),
363
384
Resolve : func (p ResolveParams ) (interface {}, error ) {
364
385
if schema , ok := p .Source .(Schema ); ok {
365
386
return schema .QueryType (), nil
@@ -370,7 +391,7 @@ func init() {
370
391
"mutationType" : & Field {
371
392
Description : `If this server supports mutation, the type that ` +
372
393
`mutation operations will be rooted at.` ,
373
- Type : typeType ,
394
+ Type : TypeType ,
374
395
Resolve : func (p ResolveParams ) (interface {}, error ) {
375
396
if schema , ok := p .Source .(Schema ); ok {
376
397
if schema .MutationType () != nil {
@@ -383,7 +404,7 @@ func init() {
383
404
"subscriptionType" : & Field {
384
405
Description : `If this server supports subscription, the type that ` +
385
406
`subscription operations will be rooted at.` ,
386
- Type : typeType ,
407
+ Type : TypeType ,
387
408
Resolve : func (p ResolveParams ) (interface {}, error ) {
388
409
if schema , ok := p .Source .(Schema ); ok {
389
410
if schema .SubscriptionType () != nil {
@@ -396,7 +417,7 @@ func init() {
396
417
"directives" : & Field {
397
418
Description : `A list of all directives supported by this server.` ,
398
419
Type : NewNonNull (NewList (
399
- NewNonNull (directiveType ),
420
+ NewNonNull (DirectiveType ),
400
421
)),
401
422
Resolve : func (p ResolveParams ) (interface {}, error ) {
402
423
if schema , ok := p .Source .(Schema ); ok {
@@ -408,7 +429,7 @@ func init() {
408
429
},
409
430
})
410
431
411
- enumValueType = NewObject (ObjectConfig {
432
+ EnumValueType = NewObject (ObjectConfig {
412
433
Name : "__EnumValue" ,
413
434
Description : "One possible value for a given Enum. Enum values are unique values, not " +
414
435
"a placeholder for a string or numeric value. However an Enum value is " +
@@ -437,8 +458,8 @@ func init() {
437
458
438
459
// Again, adding field configs to __Type that have cyclic reference here
439
460
// because golang don't like them too much during init/compile-time
440
- typeType .AddFieldConfig ("fields" , & Field {
441
- Type : NewList (NewNonNull (fieldType )),
461
+ TypeType .AddFieldConfig ("fields" , & Field {
462
+ Type : NewList (NewNonNull (FieldType )),
442
463
Args : FieldConfigArgument {
443
464
"includeDeprecated" : & ArgumentConfig {
444
465
Type : Boolean ,
@@ -476,8 +497,8 @@ func init() {
476
497
return nil , nil
477
498
},
478
499
})
479
- typeType .AddFieldConfig ("interfaces" , & Field {
480
- Type : NewList (NewNonNull (typeType )),
500
+ TypeType .AddFieldConfig ("interfaces" , & Field {
501
+ Type : NewList (NewNonNull (TypeType )),
481
502
Resolve : func (p ResolveParams ) (interface {}, error ) {
482
503
switch ttype := p .Source .(type ) {
483
504
case * Object :
@@ -486,8 +507,8 @@ func init() {
486
507
return nil , nil
487
508
},
488
509
})
489
- typeType .AddFieldConfig ("possibleTypes" , & Field {
490
- Type : NewList (NewNonNull (typeType )),
510
+ TypeType .AddFieldConfig ("possibleTypes" , & Field {
511
+ Type : NewList (NewNonNull (TypeType )),
491
512
Resolve : func (p ResolveParams ) (interface {}, error ) {
492
513
switch ttype := p .Source .(type ) {
493
514
case * Interface :
@@ -498,8 +519,8 @@ func init() {
498
519
return nil , nil
499
520
},
500
521
})
501
- typeType .AddFieldConfig ("enumValues" , & Field {
502
- Type : NewList (NewNonNull (enumValueType )),
522
+ TypeType .AddFieldConfig ("enumValues" , & Field {
523
+ Type : NewList (NewNonNull (EnumValueType )),
503
524
Args : FieldConfigArgument {
504
525
"includeDeprecated" : & ArgumentConfig {
505
526
Type : Boolean ,
@@ -525,8 +546,8 @@ func init() {
525
546
return nil , nil
526
547
},
527
548
})
528
- typeType .AddFieldConfig ("inputFields" , & Field {
529
- Type : NewList (NewNonNull (inputValueType )),
549
+ TypeType .AddFieldConfig ("inputFields" , & Field {
550
+ Type : NewList (NewNonNull (InputValueType )),
530
551
Resolve : func (p ResolveParams ) (interface {}, error ) {
531
552
switch ttype := p .Source .(type ) {
532
553
case * InputObject :
@@ -539,15 +560,15 @@ func init() {
539
560
return nil , nil
540
561
},
541
562
})
542
- typeType .AddFieldConfig ("ofType" , & Field {
543
- Type : typeType ,
563
+ TypeType .AddFieldConfig ("ofType" , & Field {
564
+ Type : TypeType ,
544
565
})
545
566
546
567
// Note that these are FieldDefinition and not FieldConfig,
547
- // so the format for args is different. d
568
+ // so the format for args is different.
548
569
SchemaMetaFieldDef = & FieldDefinition {
549
570
Name : "__schema" ,
550
- Type : NewNonNull (schemaType ),
571
+ Type : NewNonNull (SchemaType ),
551
572
Description : "Access the current type schema of this server." ,
552
573
Args : []* Argument {},
553
574
Resolve : func (p ResolveParams ) (interface {}, error ) {
@@ -556,7 +577,7 @@ func init() {
556
577
}
557
578
TypeMetaFieldDef = & FieldDefinition {
558
579
Name : "__type" ,
559
- Type : typeType ,
580
+ Type : TypeType ,
560
581
Description : "Request the type information of a single type." ,
561
582
Args : []* Argument {
562
583
{
0 commit comments