Skip to content

Commit b6cd960

Browse files
committed
Use types from ast package
1 parent 5db715d commit b6cd960

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/exec/validate.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/graph-gophers/graphql-go/ast"
78
"github.com/graph-gophers/graphql-go/errors"
89
"github.com/graph-gophers/graphql-go/internal/exec/resolvable"
910
"github.com/graph-gophers/graphql-go/internal/exec/selected"
10-
"github.com/graph-gophers/graphql-go/types"
1111
)
1212

1313
func collectFieldsToValidate(sels []selected.Selection, s *resolvable.Schema, fields *[]*fieldToValidate, fieldByAlias map[string]*fieldToValidate) {
@@ -69,18 +69,18 @@ func validateFieldSelection(ctx context.Context, s *resolvable.Schema, f *fieldT
6969
return validateSelectionSet(ctx, f.sels, f.field.Type, path, s)
7070
}
7171

72-
func validateSelectionSet(ctx context.Context, sels []selected.Selection, typ types.Type, path *pathSegment, s *resolvable.Schema) []*errors.QueryError {
72+
func validateSelectionSet(ctx context.Context, sels []selected.Selection, typ ast.Type, path *pathSegment, s *resolvable.Schema) []*errors.QueryError {
7373
t, _ := unwrapNonNull(typ)
7474

7575
switch t.(type) {
76-
case *types.ObjectTypeDefinition, *types.InterfaceTypeDefinition, *types.Union:
76+
case *ast.ObjectTypeDefinition, *ast.InterfaceTypeDefinition, *ast.Union:
7777
return validateSelections(ctx, sels, path, s)
7878
}
7979

8080
switch t := t.(type) {
81-
case *types.List:
81+
case *ast.List:
8282
return validateList(ctx, sels, t, path, s)
83-
case *types.ScalarTypeDefinition, *types.EnumTypeDefinition:
83+
case *ast.ScalarTypeDefinition, *ast.EnumTypeDefinition:
8484
// Field resolution already validated, don't need to check the value
8585
default:
8686
panic(fmt.Sprintf("unexpected type %T", t))
@@ -100,7 +100,7 @@ func validateSelections(ctx context.Context, sels []selected.Selection, path *pa
100100
return errs
101101
}
102102

103-
func validateList(ctx context.Context, sels []selected.Selection, typ *types.List, path *pathSegment, s *resolvable.Schema) []*errors.QueryError {
103+
func validateList(ctx context.Context, sels []selected.Selection, typ *ast.List, path *pathSegment, s *resolvable.Schema) []*errors.QueryError {
104104
// For lists, we only need to apply validation once. Nothing has been evaluated, so we have no list, and need to use '0' as the path index
105105
return validateSelectionSet(ctx, sels, typ.OfType, &pathSegment{path, 0}, s)
106106
}

0 commit comments

Comments
 (0)