-
Notifications
You must be signed in to change notification settings - Fork 275
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 doesn't honor default enum values #1979
Comments
@andrew-kolesnikov could you show a reproducible test case? With this schema: enum Terminal {
WEB,
MOBILE
}
type Query{
test: String
}
type Mutation {
page(channel: Terminal! = WEB): String
} and this query: mutation GetPage($terminal: Terminal) {
page(channel: $terminal)
} right now it works, but if you could show me something with the same shape as your query that would help |
ok I see the error with mutation GetPage($terminal: Terminal!) {
page(channel: $terminal)
} |
hmm no, that fails because the operation itself actually needs a value. Can you show an example query? |
Using the following schema: type Mutation{
foo(input: FooInput!): FooResponse!
}
input FooInput {
enumWithDefault: EnumWithDefault! = WEB
}
enum EnumWithDefault {
WEB
MOBILE
}
Request the following: mutation foo($input: FooInput!) {
foo (input: $input) {
__typename
}}
Observe failed validation: {
"errors": [
{
"message": "invalid type for variable: 'input'",
"locations": [],
"path": null,
"extensions": {
"type": "ValidationInvalidTypeVariable",
"name": "input"
}
}
]
} Yet |
alright, thanks! |
Fix #1979 When validating variables, we should use default values for object fields if applicable
Our particular spec has a mutation input containing
channel: SimpleStringEnum! = WEB
but to pass validation, router expects input to still have that field explicitly set.Steps to reproduce the behavior:
{"input":{"channel":"MOBILE",...}}} passes validation
{"input":{...}}} doesn't with a cryptic error
response: {“errors”:[{“message”:“invalid type for variable: ‘input’“,”locations”:[],“path”:null,“extensions”:{“type”:“ValidationInvalidTypeVariable”,“name”:“input”}}]}
The text was updated successfully, but these errors were encountered: