-
Notifications
You must be signed in to change notification settings - Fork 664
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
Allows nullable variables in non-null locations #3227
Comments
Hi 👋
This is most likely a bug in Apollo Android. The spec allows nullable variables in non-null locations when a default value exist:
This is most likely an error in your backend. There was a change in the GraphQL spec to support that use case: graphql/graphql-spec#418 that is most likely not ported there. Overall both queries appear valid but trigger bugs in either Apollo Android or your backend validation logic. I'll look into the Apollo Android part. Until this is fixed, a workaround would be to remove the defaultValue and always set the variable from Kotlin code. Or if that's too many places to change, maybe add a Kotlin wrapper? Something like:
|
As a follow up, what needs to be changed is the input values coercion/validation logic: https://github.com/apollographql/apollo-android/blob/437bc50f4a893b6a06b8cb992fb8db1fe62b3ad2/apollo-graphql-ast/src/main/kotlin/com/apollographql/apollo3/ast/internal/InputValueValidationScope.kt#L39 |
thanks for the following up. On my client side, i have replaced all query in which contains both required type + default value combination into required type only, the default value, on the other hand are assigned through kotlin code. |
Currently I am migrating AppSync sdk (although it embedded an internal Apollo sdk, it is way too outdated) to Apollo sdk v2.
However, I found that below query will be compile error:
because in query definition, the field
first
is optional with default value, but in schema queryfirst
is required.So i change the query to below:
Then apollo client can generate query class successfully, and project got compile. Yeah!!
However, the problem is apollo client respond error because of
Variable "$first" of type "Int!" is required and will not use the default value. Perhaps you meant to use type "Int".
I would suggest
The text was updated successfully, but these errors were encountered: