Skip to content
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

Support required arguments with default values #2356

Closed
bessey opened this issue Jun 28, 2019 · 5 comments
Closed

Support required arguments with default values #2356

bessey opened this issue Jun 28, 2019 · 5 comments

Comments

@bessey
Copy link
Contributor

bessey commented Jun 28, 2019

The GraphQL spec has for some time supported required arguments with default values, however graphql-ruby (1.9) appears not to support this

argument :id, ID, required: true, default_value: "123"

results in the schema compilation error:
Query is invalid: field "account" argument "id" Variable id of type "ID!" is required and will not use the default value. Perhaps you meant to use type "ID".

This seems like a very legitimate use case to me, a less contrived example:

argument :hideDisabledAccounts, Boolean, required: true, default_value: false
# vs
argument :hideDisabledAccounts, Boolean, required: false

As Rubyists we understand that nil is false-y, so the behaviour here is roughly the same, but from the outside (and the inside) the 1st definition's behaviour seems to me much clearer than the 2nd, in the case where no value is provided.

References:
This behaviour being requested in GraphQL reference implementation, and delivered
Merged spec change which adds "Non-null arguments and input object fields are no longer required to be provided a value/variable if that argument also supplies a default value."

@rmosolgo
Copy link
Owner

Thanks for opening this conversation and including those links. It looks like I missed that spec update 🙈 I agree it should work the way the spec says!

@modosc
Copy link
Contributor

modosc commented Aug 7, 2019

@rmosolgo any chance you could check out my pr? we ran into some issues recently that this would help solve, thanks!

rmosolgo added a commit that referenced this issue Aug 8, 2019
Support required arguments with default values [fixes #2356]
@modosc
Copy link
Contributor

modosc commented Aug 20, 2019

@rmosolgo are there any blockers from getting this released that i can help out with?

@rmosolgo
Copy link
Owner

No blockers, just released 1.9.10 🚢 !

@modosc
Copy link
Contributor

modosc commented Aug 21, 2019

thanks! 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants