@@ -403,9 +403,8 @@ func (gt *Object) AddFieldConfig(fieldName string, fieldConfig *Field) {
403
403
if fieldName == "" || fieldConfig == nil {
404
404
return
405
405
}
406
- switch gt .typeConfig .Fields .(type ) {
407
- case Fields :
408
- gt .typeConfig .Fields .(Fields )[fieldName ] = fieldConfig
406
+ if fields , ok := gt .typeConfig .Fields .(Fields ); ok {
407
+ fields [fieldName ] = fieldConfig
409
408
gt .initialisedFields = false
410
409
}
411
410
}
@@ -424,11 +423,11 @@ func (gt *Object) Fields() FieldDefinitionMap {
424
423
}
425
424
426
425
var configureFields Fields
427
- switch gt .typeConfig .Fields .(type ) {
426
+ switch fields := gt .typeConfig .Fields .(type ) {
428
427
case Fields :
429
- configureFields = gt . typeConfig . Fields .( Fields )
428
+ configureFields = fields
430
429
case FieldsThunk :
431
- configureFields = gt . typeConfig . Fields .( FieldsThunk ) ()
430
+ configureFields = fields ()
432
431
}
433
432
434
433
gt .fields , gt .err = defineFieldMap (gt , configureFields )
@@ -442,11 +441,11 @@ func (gt *Object) Interfaces() []*Interface {
442
441
}
443
442
444
443
var configInterfaces []* Interface
445
- switch gt .typeConfig .Interfaces .(type ) {
444
+ switch iface := gt .typeConfig .Interfaces .(type ) {
446
445
case InterfacesThunk :
447
- configInterfaces = gt . typeConfig . Interfaces .( InterfacesThunk ) ()
446
+ configInterfaces = iface ()
448
447
case []* Interface :
449
- configInterfaces = gt . typeConfig . Interfaces .([] * Interface )
448
+ configInterfaces = iface
450
449
case nil :
451
450
default :
452
451
gt .err = fmt .Errorf ("Unknown Object.Interfaces type: %T" , gt .typeConfig .Interfaces )
@@ -721,9 +720,8 @@ func (it *Interface) AddFieldConfig(fieldName string, fieldConfig *Field) {
721
720
if fieldName == "" || fieldConfig == nil {
722
721
return
723
722
}
724
- switch it .typeConfig .Fields .(type ) {
725
- case Fields :
726
- it .typeConfig .Fields .(Fields )[fieldName ] = fieldConfig
723
+ if fields , ok := it .typeConfig .Fields .(Fields ); ok {
724
+ fields [fieldName ] = fieldConfig
727
725
it .initialisedFields = false
728
726
}
729
727
}
@@ -742,11 +740,11 @@ func (it *Interface) Fields() (fields FieldDefinitionMap) {
742
740
}
743
741
744
742
var configureFields Fields
745
- switch it .typeConfig .Fields .(type ) {
743
+ switch fields := it .typeConfig .Fields .(type ) {
746
744
case Fields :
747
- configureFields = it . typeConfig . Fields .( Fields )
745
+ configureFields = fields
748
746
case FieldsThunk :
749
- configureFields = it . typeConfig . Fields .( FieldsThunk ) ()
747
+ configureFields = fields ()
750
748
}
751
749
752
750
it .fields , it .err = defineFieldMap (it , configureFields )
@@ -1113,11 +1111,11 @@ func (gt *InputObject) defineFieldMap() InputObjectFieldMap {
1113
1111
fieldMap InputObjectConfigFieldMap
1114
1112
err error
1115
1113
)
1116
- switch gt .typeConfig .Fields .(type ) {
1114
+ switch fields := gt .typeConfig .Fields .(type ) {
1117
1115
case InputObjectConfigFieldMap :
1118
- fieldMap = gt . typeConfig . Fields .( InputObjectConfigFieldMap )
1116
+ fieldMap = fields
1119
1117
case InputObjectConfigFieldMapThunk :
1120
- fieldMap = gt . typeConfig . Fields .( InputObjectConfigFieldMapThunk ) ()
1118
+ fieldMap = fields ()
1121
1119
}
1122
1120
resultFieldMap := InputObjectFieldMap {}
1123
1121
@@ -1283,7 +1281,7 @@ func (gl *NonNull) Error() error {
1283
1281
return gl .err
1284
1282
}
1285
1283
1286
- var NameRegExp , _ = regexp .Compile ("^[_a-zA-Z][_a-zA-Z0-9]*$" )
1284
+ var NameRegExp = regexp .MustCompile ("^[_a-zA-Z][_a-zA-Z0-9]*$" )
1287
1285
1288
1286
func assertValidName (name string ) error {
1289
1287
return invariantf (
0 commit comments