Skip to content

Commit

Permalink
Move input validation into gqlparser see vektah/gqlparser#96
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Scarr committed Feb 6, 2019
1 parent 4213186 commit b26b915
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 74 deletions.
10 changes: 0 additions & 10 deletions codegen/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ func (f *FieldArgument) Stream() bool {
}

func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) {
def := b.Schema.Types[arg.Type.Name()]
if !def.IsInputType() {
return nil, errors.Errorf(
"cannot use %s as argument %s because %s is not a valid input type",
arg.Type.String(),
arg.Name,
def.Kind,
)
}

tr, err := b.Binder.TypeReference(arg.Type, nil)
if err != nil {
return nil, err
Expand Down
5 changes: 0 additions & 5 deletions codegen/directive.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {

var args []*FieldArgument
for _, arg := range dir.Arguments {
def := b.Schema.Types[arg.Type.Name()]
if !def.IsInputType() {
return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name)
}

tr, err := b.Binder.TypeReference(arg.Type, nil)
if err != nil {
return nil, err
Expand Down
35 changes: 0 additions & 35 deletions codegen/errors_test.go

This file was deleted.

12 changes: 0 additions & 12 deletions codegen/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e
return nil, err
}

def := b.Schema.Types[field.Type.Name()]

if obj.Kind == ast.InputObject && !def.IsInputType() {
return nil, errors.Errorf(
"%s.%s: cannot use %s because %s is not a valid input type",
obj.Name,
field.Name,
def.Name,
def.Kind,
)
}

f := Field{
FieldDefinition: field,
Object: obj,
Expand Down
7 changes: 0 additions & 7 deletions codegen/testdata/typeinput.graphqls

This file was deleted.

5 changes: 0 additions & 5 deletions codegen/testdata/unioninput.graphqls

This file was deleted.

0 comments on commit b26b915

Please sign in to comment.