-
Notifications
You must be signed in to change notification settings - Fork 158
Fix nullability of GraphQL scalar types when passed as required arguments #2618
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,9 @@ def type_for(type, ignore_nilable_wrapper: false, prepare_method: nil) | |
| signature = Runtime::Reflection.signature_of(method) | ||
| return_type = signature&.return_type | ||
|
|
||
| valid_return_type?(return_type) ? return_type.to_s : "T.untyped" | ||
| # Wrap as non-nilable for required arguments. `coerce_input` supports both | ||
| # required and optional; optional arguments are re-wrapped below based on `type.non_null?` | ||
| valid_return_type?(return_type) ? RBIHelper.as_non_nilable_type(return_type.to_s) : "T.untyped" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should be using Thoughts @KaanOzkan ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, it's much faster, opened #2625 |
||
| when GraphQL::Schema::InputObject.singleton_class | ||
| type_for_constant(unwrapped_type) | ||
| when Module | ||
|
|
||
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.
Can you give context on why we can assume
coerce_inputcan't return nil?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.
coerce_inputhas to handle both required and optional arguments, and for an optional argument it still gets called with an input ofnil. So when we have a required argument the signature should no longer have aT.nilable(...)since we know the output won't benil.Uh oh!
There was an error while loading. Please reload this page.
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.
Let's capture this in a comment since there's quite a bit going on, something like
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.
Great, I've updated it with the comment as suggested.