Closed meiamsome closed 2 years ago
@meiamsome thanks!
I hope to have time to look at this this week, but I wanted to drop by and say this is an amazing bug report, thank you!
@LegNeato it's OK, we have this on @ilslv's schedule. He will address this in a near time.
It also makes sense to port all tests from graphql-js before releasing 0.16.0. I guess we have much more cases of spec diversion.
@meiamsome thank you very much for bringing this up! Hope, with the #1080 being merged, this is fixed finally.
Describe the bug The current behaviour for default values does not align with the GraphQL spec, or the reference implementation:
For a non-null field with a default value, it should be possible to override the value with a null value:
Currently Juniper takes the default value in this case.
A similar issue applies for variables:
Passing an explicit
null
as the value for$arg
should pass through to thetest
resolver.When declaring a non-optional field as having a default value, Juniper currently downgrades the type to non-null when adding the default. This incorrectly implies that an explicit null is allowable.
E.g.:
Results in an exposed schema that is similar to this:
instead of:
The GraphQL Spec
Under Input Coercion section of the spec, it is specified that the default value should only apply if no value is provided:
And additionally that an explicit
null
is considered semantically different to having not provided a value:And similarly for variables, the same is true:
Comparison to the reference implementation
I have created a repo here with a suite of tests against both Juniper and graphql-js that can be used for comparison: https://github.com/meiamsome/juniper-default-value
The results of the comparision tests are as follows: graphql-js:
juniper: