-
-
Notifications
You must be signed in to change notification settings - Fork 565
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
Resolve ambiguous null
interpretation with regards to defaultValue
s
#262
Conversation
I think we should wait for a fix in the reference implementation. |
The reference implementation merged the referenced PR in April. |
Needs rebase tho |
Also, i think spec and reference implementation changed since this PR. Explicit "null" don't sets value to default anymore. |
/** | ||
* @it when null value provided directly | ||
*/ | ||
public function testWhenNullValueProvidedDirectly() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function testWhenNullValueProvidedDirectly() | |
public function testWhenNullValueProvidedDirectly() : void |
/** | ||
* @it when null value variable provided | ||
*/ | ||
public function testWhenNullValueVariableProvided() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function testWhenNullValueVariableProvided() | |
public function testWhenNullValueVariableProvided() : void |
fieldWithDefaultArgumentValue(input: $optional) | ||
}'); | ||
|
||
$this->assertEquals( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEquals( | |
self::assertEquals( |
fieldWithDefaultArgumentValue(input: null) | ||
}'); | ||
|
||
$this->assertEquals( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEquals( | |
self::assertEquals( |
This looks like an important bugfix, especially considering that the reference implementation is now also fixed: graphql/graphql-js#1274 The spec definitely says that explicit null is not the same as omitting the argument: https://graphql.github.io/graphql-spec/draft/#sec-Null-Value @vladar anything i can do to move this along? |
I no longer have interest in fixing this specific issue to ensure it matches the current reference implementation. |
@vladar i would be willing to champion this and create a new PR, ok? |
@spawnia Yeah, as long as it matches reference implementation and spec, sure. |
@spawnia thanks %) |
There is some ambiguity in both the GraphQL spec and various implementations with regards to when
defaultValue
s are applied to arguments.A spec change to resolve this is being considered and there is a proposed PR for the JS implementation as well.
I have run into this during use of graphql-php where I wanted
defaultValue
to be applied for an optional argument (which can't benull
either), but the client used sendsnull
as the value for the argument. I expected thedefaultValue
to be substituted, butnull
was the coerced value instead.This PR tries to apply a similar fix for the ambiguity in the above PR for the JS implementation, always using the
defaultValue
for a node if the value is explicitly sent asnull
(either directly or via variables).