-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Allow nullable variables for non-null arguments that have defaults; allow scalar variable to list types #3662
Conversation
Todo: double check we have tests that ensure that type validation disallows |
if (sup.ResolvedType is NonNullGraphType sup2) | ||
{ | ||
// >> - Let {nullableItemLocationType} be the unwrapped nullable type of {itemLocationType}. | ||
// >> - Return {AreTypesCompatible(variableType, nullableItemLocationType)}. | ||
return IsSubtypeOf(maybeSubType, sup2); | ||
} | ||
else | ||
{ | ||
// >> - Otherwise, return {AreTypesCompatible(variableType, itemLocationType)}. | ||
return IsSubtypeOf(maybeSubType, sup.ResolvedType!, allowScalarsForLists); | ||
} |
Check notice
Code scanning / CodeQL
Missed ternary opportunity Note
Todo: fix final failing test to prevent allowing null for a non-null input object field |
[InlineData("query q10 { dummyList(arg: null) }", null, | ||
"Argument 'arg' has invalid value. Expected '!', found null.")] | ||
[InlineData("query q11 { dummyNestedList(arg: null) }", null, | ||
"Argument 'arg' has invalid value. Expected '!', found null.")] |
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.
These error messages could be cleaned up.
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## master #3662 +/- ##
==========================================
+ Coverage 84.14% 84.24% +0.09%
==========================================
Files 409 410 +1
Lines 18234 18523 +289
Branches 2856 2909 +53
==========================================
+ Hits 15343 15604 +261
- Misses 2215 2236 +21
- Partials 676 683 +7
|
@sungam3r This PR contains bug fixes for type validation of variables:
It also allows passing
I will merge this shortly unless you have comments. |
See:
Sample query which would fail validation:
where
dummyArg
was defined as[String]
. However, these scenarios worked correctly:and
where variables were:
Now the original query at the top passes validation and works as described in the GraphQL spec.
Note that the spec is slightly in conflict with the description of rule All Variable Usages Are Allowed.
See:
This PR also fixes some out-of-spec behavior during coercion of arguments that have default values:
And I added a lot more tests to cover various of these scenarios.