-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Field error from list arg with nullable variable entry (nullable=optional clash?) #1002
Comments
Yes this issue is terrible! It’s impossible to get the client to do the right thing here, unless we switched to requiring non-nullable usages to be defined by explicitly non-nullable variables. I personally am of the opinion that allowing nullable-with-default variables to be used in non-nullable positions was a mistake. As a note, FB’s servers are not spec compliant in this case, as we convert an explicitly null variable with a default value into the default value. So in the above request I.e. instead of
we do I’m fairly certain the FB-server behavior is the root cause of this weird anti-pattern, but now it would require a version bump to fix it, I think. Alternatively we could make it explicit that |
This is already known in the spec: http://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed.Allowing-optional-variables-when-default-values-exist
|
Maybe we should add a note here? https://spec.graphql.org/draft/#note-65769 |
|
Related: #418 |
(prev post deleted, sorry for distraction) |
Consider the following currently valid schema and query:
With the following variables:
Now following through 6.1.2 Coercing Variable Values:
For the variable definition
$number: Int = 3
:variableType
isInt
(NOTInt!
).defaultValue
is3
hasValue
istrue
sincenumber
is provided in variables (even though it's null)value
isnull
Thus
coercedValues
becomes{ number: null }
.When it comes to executing the field, this results in CoerceArgumentValues() raising a field error at 5.j.iii.1 (since
[1, null , 3]
cannot be coerced to[Int!]!
).Had the query have been defined with
($number: Int! = 3)
then this error could not have occurred; but we explicitly allow the nullable Int with default in IsVariableUsageAllowed(). Presumably this is so that we can allow a default value to apply in the list, except this is aListValue
so there cannot be a default value there.We've discussed "optionality" versus "nullability" a few times, but I'd like to get the WG's read on this.
Reproduction:
The text was updated successfully, but these errors were encountered: