graphql-remote_loader icon indicating copy to clipboard operation
graphql-remote_loader copied to clipboard

Querying camelCase but receiving snake_case

Open donni106 opened this issue 5 years ago • 4 comments

Aliases are working fine. I can rename things in my query. But the bad thing is, that in the result everything is snake_cased.

Is this line responsible for that?

https://github.com/d12/graphql-remote_loader/blob/6ee709baab2a4d5bc05208be927a233254fca982/lib/graphql/remote_loader/loader.rb#L156

Is the underscore necessary? I am processing the resulting data in JavaScript with an existing code, based on camelCase data. There was a different GraphQL server before. Now I am merging things together with your package and encountered the problem.

donni106 avatar Jun 19 '20 15:06 donni106

Hey @donni106 , We underscore because that's the convention in Ruby when parsing GraphQL results. I can see the usecase for non-underscored results though, I can look into putting some sort of optional functionality together soon. Or, if you have time, feel free to PR :)

d12 avatar Jun 22 '20 13:06 d12

It would be nice, if we could find an optional way. For now, I am transforming the keys with deeply renaming them in the frontend before accessing the resulting data.

donni106 avatar Jun 26 '20 14:06 donni106

I should be able to get to this in the next few days

d12 avatar Jun 30 '20 13:06 d12

This fell off my radar for a bit, I don't have a ton of time right now for non-functional or non-significant changes, but this should be an easy PR if anyone wants to add a camelCase config option.

d12 avatar Sep 14 '20 14:09 d12