-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Dataloaders are changing the response order #4252
Comments
Hi! Thanks for the detailed report. Although it's in the spec, GraphQL-Ruby has never actually enforced key-value pair order in the result set 🙈 (Besides using dataloader, using GraphQL-Batch would also cause the results to be out-of-order.) I'm definitely open to matching the spec here, but out of curiosity, how did this become a problem for you? |
Hi! First of all, it's a pleasure for me to be answered by you. You did a great job with ruby-graphql. Actually, you still have done a great job. Thank you so much. Well, let me explain how it is affecting me. I'm applying ruby-graph in a huge software. We're doing this about two years. During this time we're maintaining rest and graphql. Some parts of the sofware are already using graphql but others not. In our rest controllers we're using graphql internally instead of regular Rails. It helped us to write all the resolvers and queries safely. In theses rest controllers, we have tests comparing the result (of graphql) with the old serializer (active model serializer). In our app, we're solving n+1 problem using active record So this weekend I resolved to study how to resolve this correctly and so stumbled in this problem. All the rest test has broken because the keys are in a different order between rest and graphql. I really don't know if it is a real problem because it's not common for me to use others graphql APIs different than ours. So I just though it was a bug. Please let me know if you need something else. Thanks! |
Thanks, @olivierbuffon ! I'm going to test and keep you in touch. |
Describe the bug
When a dataloader is used, the order of fields in the response is affected.
All the fields using dataloaders are delivered after the others fields.
According to GraphQL Specs the order of the fields in the answer must follow the order of fields in the query.
Versions
ruby-graphql
: 2.0.15rails
: 7.0.4ruby
: 3.0.3GraphQL schema
I've prepared a complete app reproducing the problem using rspec.
https://github.com/cesarjr/graphql-dataloader
Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?
GraphQL query
Example GraphQL query and response (if query execution is involved)
Steps to reproduce
Steps to reproduce the behavior
Expected behavior
It is expected that
city
to be returned first thanseller
as it was queried.Actual behavior
Look that
seller
is being returned before thancity
.Additional context
I created an app very simples rails app reproducing the problem.
https://github.com/cesarjr/graphql-dataloader
The text was updated successfully, but these errors were encountered: