-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Validation of argument default values #2606
Comments
@danielrearden Thanks for extracting this issue 👍 It's a general issue with SDL validation and should be done in It's even more serious in a sense we don't validate argument of directives it's serious problem related to how input SomeInput {
field: SomeOtherInputObject = { enum: INVALID }
}
input SomeOtherInputObject {
enum: SomeEnum
}
enum SomeEnum {
TEST
} It's planned for |
@IvanGoncharov Thanks for the context and for the clarification around labeling. I used SDL in the above example, but the same issue applies to schemas built programmatically:
|
@danielrearden It's kind of hard to do validation of default values inside |
👍 Just wanted to clarify the scope of the issue. |
Although... I do wonder if we couldn't just utilize |
@danielrearden |
@danielrearden To be honest default values and custom scalars are two most problematic places at the moment and their combination is an absolute nightmare. |
@IvanGoncharov Can It appears that graphql-js/src/utilities/valueFromAST.js Line 137 in a75e95b
|
Closing this issue, tracked in #3814 |
Any default values provided when defining an argument are currently not validated against that argument's type. So a
Float
argument could be passed a string as a default value and this schema will be considered valid. Moreover, the default value will be passed as-is to the resolver instead of being coerced into an appropriate value.As far as I can tell, the current behavior is inline with the spec. But it seems counterintuitive that doing something like this would be valid:
We do validate default values on variables, so I think it's reasonable to expect at least consistency with that behavior. At the very least, I think
validateSchema
should be modified to validate the provided values against the argument type. I'm less certain about coercing the values, but off-hand it seems like desirable behavior as well.The text was updated successfully, but these errors were encountered: