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

Query::Arguments#to_h may return nested Arguments objects #81

Closed
kliuless opened this issue Jan 8, 2016 · 3 comments
Closed

Query::Arguments#to_h may return nested Arguments objects #81

kliuless opened this issue Jan 8, 2016 · 3 comments

Comments

@kliuless
Copy link
Contributor

kliuless commented Jan 8, 2016

I have a mutation that accepts an input_field a, which is an input object type with a field b.
In the mutation resolver, the inputs argument is something like this:

#<GraphQL::Query::Arguments:0x007f993d572aa0
 @hash={"a"=>#<GraphQL::Query::Arguments:0x007f993d572960 @hash={"b"=>5}, @values={"b"=>5}>},
 @values={"a"=>#<GraphQL::Query::Arguments:0x007f993d572960 @hash={"b"=>5}, @values={"b"=>5}>}>

calling to_h on it merely returns @hash, so I need to call to_h at every depth.

When calling Arguments.new on a nested hash, it recursively creates Arguments objects when setting @value, but the original is retained in @hash.
However when handling a real request, even the @hash has nested Arguments objects.
Is there some built-in way to unpack the Arguments recursively?

@davidnorth
Copy link
Contributor

When I added that feature I just wanted to turn the arguments for my object input types into a hash for Rails' sake, I hadn't considered converting the entire args object. I agree that'd be the expected behaviour. It'd be easy enough to implement if you'd like to have a go.

@rmosolgo
Copy link
Owner

rmosolgo commented Jan 8, 2016

No built-in way, but +1 for recursive to_h-ing!

@rmosolgo
Copy link
Owner

fixed by 6e3d6f0

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