Skip to content

Commit

Permalink
Merge branch 'master' into regexpMust
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-ramon committed Jul 28, 2018
2 parents 79674a8 + 4620584 commit 1e154ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
34 changes: 16 additions & 18 deletions definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ func (gt *Object) AddFieldConfig(fieldName string, fieldConfig *Field) {
if fieldName == "" || fieldConfig == nil {
return
}
switch gt.typeConfig.Fields.(type) {
case Fields:
gt.typeConfig.Fields.(Fields)[fieldName] = fieldConfig
if fields, ok := gt.typeConfig.Fields.(Fields); ok {
fields[fieldName] = fieldConfig
gt.initialisedFields = false
}
}
Expand All @@ -424,11 +423,11 @@ func (gt *Object) Fields() FieldDefinitionMap {
}

var configureFields Fields
switch gt.typeConfig.Fields.(type) {
switch fields := gt.typeConfig.Fields.(type) {
case Fields:
configureFields = gt.typeConfig.Fields.(Fields)
configureFields = fields
case FieldsThunk:
configureFields = gt.typeConfig.Fields.(FieldsThunk)()
configureFields = fields()
}

gt.fields, gt.err = defineFieldMap(gt, configureFields)
Expand All @@ -442,11 +441,11 @@ func (gt *Object) Interfaces() []*Interface {
}

var configInterfaces []*Interface
switch gt.typeConfig.Interfaces.(type) {
switch iface := gt.typeConfig.Interfaces.(type) {
case InterfacesThunk:
configInterfaces = gt.typeConfig.Interfaces.(InterfacesThunk)()
configInterfaces = iface()
case []*Interface:
configInterfaces = gt.typeConfig.Interfaces.([]*Interface)
configInterfaces = iface
case nil:
default:
gt.err = fmt.Errorf("Unknown Object.Interfaces type: %T", gt.typeConfig.Interfaces)
Expand Down Expand Up @@ -721,9 +720,8 @@ func (it *Interface) AddFieldConfig(fieldName string, fieldConfig *Field) {
if fieldName == "" || fieldConfig == nil {
return
}
switch it.typeConfig.Fields.(type) {
case Fields:
it.typeConfig.Fields.(Fields)[fieldName] = fieldConfig
if fields, ok := it.typeConfig.Fields.(Fields); ok {
fields[fieldName] = fieldConfig
it.initialisedFields = false
}
}
Expand All @@ -742,11 +740,11 @@ func (it *Interface) Fields() (fields FieldDefinitionMap) {
}

var configureFields Fields
switch it.typeConfig.Fields.(type) {
switch fields := it.typeConfig.Fields.(type) {
case Fields:
configureFields = it.typeConfig.Fields.(Fields)
configureFields = fields
case FieldsThunk:
configureFields = it.typeConfig.Fields.(FieldsThunk)()
configureFields = fields()
}

it.fields, it.err = defineFieldMap(it, configureFields)
Expand Down Expand Up @@ -1113,11 +1111,11 @@ func (gt *InputObject) defineFieldMap() InputObjectFieldMap {
fieldMap InputObjectConfigFieldMap
err error
)
switch gt.typeConfig.Fields.(type) {
switch fields := gt.typeConfig.Fields.(type) {
case InputObjectConfigFieldMap:
fieldMap = gt.typeConfig.Fields.(InputObjectConfigFieldMap)
fieldMap = fields
case InputObjectConfigFieldMapThunk:
fieldMap = gt.typeConfig.Fields.(InputObjectConfigFieldMapThunk)()
fieldMap = fields()
}
resultFieldMap := InputObjectFieldMap{}

Expand Down
8 changes: 4 additions & 4 deletions language/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ type Parser struct {

func Parse(p ParseParams) (*ast.Document, error) {
var sourceObj *source.Source
switch p.Source.(type) {
switch src := p.Source.(type) {
case *source.Source:
sourceObj = p.Source.(*source.Source)
sourceObj = src
default:
body, _ := p.Source.(string)
sourceObj = source.NewSource(&source.Source{Body: []byte(body)})
Expand All @@ -83,9 +83,9 @@ func Parse(p ParseParams) (*ast.Document, error) {
func parseValue(p ParseParams) (ast.Value, error) {
var value ast.Value
var sourceObj *source.Source
switch p.Source.(type) {
switch src := p.Source.(type) {
case *source.Source:
sourceObj = p.Source.(*source.Source)
sourceObj = src
default:
body, _ := p.Source.(string)
sourceObj = source.NewSource(&source.Source{Body: []byte(body)})
Expand Down

0 comments on commit 1e154ea

Please sign in to comment.