diff --git a/introspection.go b/introspection.go index 5e628e45..de0714aa 100644 --- a/introspection.go +++ b/introspection.go @@ -550,8 +550,7 @@ func init() { TypeType.AddFieldConfig("interfaces", &Field{ Type: NewList(NewNonNull(TypeType)), Resolve: func(p ResolveParams) (interface{}, error) { - switch ttype := p.Source.(type) { - case *Object: + if ttype, ok := p.Source.(*Object); ok { return ttype.Interfaces(), nil } return nil, nil @@ -579,8 +578,7 @@ func init() { }, Resolve: func(p ResolveParams) (interface{}, error) { includeDeprecated, _ := p.Args["includeDeprecated"].(bool) - switch ttype := p.Source.(type) { - case *Enum: + if ttype, ok := p.Source.(*Enum); ok { if includeDeprecated { return ttype.Values(), nil } @@ -599,8 +597,7 @@ func init() { TypeType.AddFieldConfig("inputFields", &Field{ Type: NewList(NewNonNull(InputValueType)), Resolve: func(p ResolveParams) (interface{}, error) { - switch ttype := p.Source.(type) { - case *InputObject: + if ttype, ok := p.Source.(*InputObject); ok { fields := []*InputObjectField{} for _, field := range ttype.Fields() { fields = append(fields, field) diff --git a/language/visitor/visitor.go b/language/visitor/visitor.go index d0d19737..70754364 100644 --- a/language/visitor/visitor.go +++ b/language/visitor/visitor.go @@ -609,19 +609,20 @@ func VisitInParallel(visitorOptsSlice ...*VisitorOptions) *VisitorOptions { Enter: func(p VisitFuncParams) (string, interface{}) { for i, visitorOpts := range visitorOptsSlice { if _, ok := skipping[i]; !ok { - switch node := p.Node.(type) { - case ast.Node: - kind := node.GetKind() - fn := GetVisitFn(visitorOpts, kind, false) - if fn != nil { - action, result := fn(p) - if action == ActionSkip { - skipping[i] = node - } else if action == ActionBreak { - skipping[i] = ActionBreak - } else if action == ActionUpdate { - return ActionUpdate, result - } + node, ok := p.Node.(ast.Node) + if !ok { + continue + } + kind := node.GetKind() + fn := GetVisitFn(visitorOpts, kind, false) + if fn != nil { + action, result := fn(p) + if action == ActionSkip { + skipping[i] = node + } else if action == ActionBreak { + skipping[i] = ActionBreak + } else if action == ActionUpdate { + return ActionUpdate, result } } } @@ -632,8 +633,7 @@ func VisitInParallel(visitorOptsSlice ...*VisitorOptions) *VisitorOptions { for i, visitorOpts := range visitorOptsSlice { skippedNode, ok := skipping[i] if !ok { - switch node := p.Node.(type) { - case ast.Node: + if node, ok := p.Node.(ast.Node); ok { kind := node.GetKind() fn := GetVisitFn(visitorOpts, kind, true) if fn != nil {