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
[1.8] Default value not provided for omitted optional input object with arguments with defaults #1678
Comments
🤔 Hmm, thanks for the detailed report. How misleading that the generated schema suggests one thing while the runtime behavior shows something else! I wonder what the spec has to say on this, which one is right... |
It actual problem? I can't reproduce in 1.9.9 with Interpreter and AST. Executing without |
Yes, with Interpreter enabled it works like it should. ✔️ @N0xFF, thank you for pointing it out! The only weird case left is that you still should specify any default value for |
We just ran into this as well in our app that doesn't yet use Interpreter. Defaults are not applied for the sub-object when the field using it has a default_value of {} (or when it has no default_value at all). Is there some way we could set the parent field's default_value to something like Types::Product::Filter.defaults? I.e.g, is there some method to generate the default output of an object? |
I'm sorry, I don't really have the bandwidth to support the old runtime these days. If you're a GraphQL-Pro customer, shoot me an email and I'll keep digging, or if anyone wants to submit a PR, I'd be happy to review and help as I can. |
Summary
If query argument is optional complex input object with arguments with default values then these default values are not provided in this input object is omitted from the query arguments
Example
Given the following query definition:
Generated docs says that
filters
have default values:If executing a query without
filters
parameter then in method empty hash is passed (not as expected):If executing a query with empty
filters
parameter then in method passed a hash with default parameter set (as expected):Environment
gem graphql 1.8.5
gem graphql-batch 0.3.9
ruby 2.5.1
rails 5.2.0
Notes
I'm naturally don't want to duplicate default values from
Types::Product::Filter
in thedefault_value
option infilters
argument definition.The text was updated successfully, but these errors were encountered: