-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Input Value Validation #330
Fix Input Value Validation #330
Conversation
Related to #325 |
Please keep this on hold - I've realised that nesting Input types don't validate correctly, which I'll look at fixing |
542d5de
to
b5ef288
Compare
@@ -1752,17 +1873,7 @@ | |||
"vars": { | |||
"colors": "BROWN" | |||
}, | |||
"errors": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case was actually an example where input coercion should have allowed the value, so expecting an error here was actually incorrect.
@@ -193,7 +193,8 @@ func validateValue(c *opContext, v *common.InputValue, val interface{}, t common | |||
} | |||
vv, ok := val.([]interface{}) | |||
if !ok { | |||
c.addErr(v.Loc, "VariablesOfCorrectType", "Variable \"%s\" has invalid type %T.\nExpected type \"%s\", found %v.", v.Name.Name, val, t, val) | |||
// Input coercion rules allow single items without wrapping array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolves the issue with input coercion for lists where a single value is supplied in variables, without a wrapping list
b5ef288
to
0bbc9de
Compare
Validating Input values supplied via variable input are supplied with the correct input structure and values. This includes ensuring that enum embedded within input values are validated as well
0bbc9de
to
3572ff4
Compare
Thank you! |
Sorry if this is me not understanding Graphql but it seems that this line will trigger an error when the input is not there https://github.com/graph-gophers/graphql-go/pull/330/files#diff-bd40f10a5bef7a0945987430ac7762bdR223 which makes sense when the inputs are required. However, it should not do that if the input is optional and not present. For example, it is failing if I don't pass a home.
Let me know if this makes sense! |
@marcoazn89 thanks for reporting this. Do you have an example to reproduce an error? |
Validating Input values supplied via variable input are supplied with the correct input structure and values. This includes ensuring that enum embedded within input values are validated as well