diff options
author | Michael Muré <batolettre@gmail.com> | 2018-12-23 17:11:37 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-12-23 17:11:37 +0100 |
commit | 1410a1af75b1ab9ea3f980a7e372728f9a123abf (patch) | |
tree | e24db8f84c48b20158b1f1fd6d281d700421279c /vendor/github.com/vektah/gqlparser/validator/vars.go | |
parent | 8fc15a032f021c855abf66ed303c003d57c340ea (diff) | |
download | git-bug-1410a1af75b1ab9ea3f980a7e372728f9a123abf.tar.gz |
upgrade gqlgen to v0.7.1
Diffstat (limited to 'vendor/github.com/vektah/gqlparser/validator/vars.go')
-rw-r--r-- | vendor/github.com/vektah/gqlparser/validator/vars.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/vendor/github.com/vektah/gqlparser/validator/vars.go b/vendor/github.com/vektah/gqlparser/validator/vars.go index 0743f5cc..aaf3a0d1 100644 --- a/vendor/github.com/vektah/gqlparser/validator/vars.go +++ b/vendor/github.com/vektah/gqlparser/validator/vars.go @@ -73,12 +73,19 @@ type varValidator struct { } func (v *varValidator) validateVarType(typ *ast.Type, val reflect.Value) *gqlerror.Error { + currentPath := v.path + resetPath := func() { + v.path = currentPath + } + defer resetPath() + if typ.Elem != nil { if val.Kind() != reflect.Slice { return gqlerror.ErrorPathf(v.path, "must be an array") } for i := 0; i < val.Len(); i++ { + resetPath() v.path = append(v.path, i) field := val.Index(i) @@ -92,8 +99,6 @@ func (v *varValidator) validateVarType(typ *ast.Type, val reflect.Value) *gqlerr if err := v.validateVarType(typ.Elem, field); err != nil { return err } - - v.path = v.path[0 : len(v.path)-1] } return nil @@ -150,15 +155,16 @@ func (v *varValidator) validateVarType(typ *ast.Type, val reflect.Value) *gqlerr for _, name := range val.MapKeys() { val.MapIndex(name) fieldDef := def.Fields.ForName(name.String()) - v.path = append(v.path, name) + resetPath() + v.path = append(v.path, name.String()) if fieldDef == nil { return gqlerror.ErrorPathf(v.path, "unknown field") } - v.path = v.path[0 : len(v.path)-1] } for _, fieldDef := range def.Fields { + resetPath() v.path = append(v.path, fieldDef.Name) field := val.MapIndex(reflect.ValueOf(fieldDef.Name)) @@ -184,8 +190,6 @@ func (v *varValidator) validateVarType(typ *ast.Type, val reflect.Value) *gqlerr if err != nil { return err } - - v.path = v.path[0 : len(v.path)-1] } default: panic(fmt.Errorf("unsupported type %s", def.Kind)) |