Skip to content

Commit

Permalink
Check for required fields while parsing the schema (graph-gophers#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
k4n4ry authored and KNiepok committed Feb 28, 2023
1 parent 23f057e commit 8e189c3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/exec/packer/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ func (b *Builder) MakeStructPacker(values []*ast.InputValueDefinition, typ refle
if sf.PkgPath != "" {
return nil, fmt.Errorf("field %q must be exported", sf.Name)
}
if _, ok := v.Type.(*ast.NonNull); ok {
if sf.Type.Kind() == reflect.Ptr {
return nil, fmt.Errorf("field %q must be a non-pointer since the parameter is required", sf.Name)
}
}

fe.index = sf.Index

ft := v.Type
Expand Down

0 comments on commit 8e189c3

Please sign in to comment.