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

Relationships break in ruby-graphql >= 1.9 #12

Open
ostrgard opened this issue Oct 11, 2019 · 4 comments
Open

Relationships break in ruby-graphql >= 1.9 #12

ostrgard opened this issue Oct 11, 2019 · 4 comments

Comments

@ostrgard
Copy link

Hi! Love this gem, thanks for creating it!

I've had issues implementing it in a project and isolated it to the fact that we used ruby-graphql >=1.9. Upgrading the root .gemspec and the tester_ar project to 1.9 allowed me to reproduce this.

The relationships are not being added to the queries as they were before. However, relocating the include Graphoid::Queries to the bottom of the model classes (or just below all relationship definitions) will add some of these, depending on the order they're being mapped over by Graphoid::Types. For instance, the User model goes first, and the Graphoid::Queries::LIST is empty, while Account goes last and is able to add User relations due to it being present in LIST by that point.

I've been looking through the ruby-graphql changelog for 1.9.0 and can't really identify some obvious reason for this to break. I checked ruby-graphql 1.8.17 which works as expected.

I'll continue investigating this...

@ostrgard
Copy link
Author

ostrgard commented Oct 14, 2019

I've narrowed this down to being introduced in this commit: rmosolgo/graphql-ruby@f06ab79. Here's the PR introducing this commit: rmosolgo/graphql-ruby#1758. It had an issue which is why it were pushed to 1.9 rather than released as a minor to 1.8. Maybe it's related.

Prior to this, the DRIVER=ar DEBUG=true bundle exec rspec test suite passed and relationships were added as expected.

I'll try and find time to dive deeper into this...

@ostrgard
Copy link
Author

This introduced connection? check seems to have a side effect that breaks this behavior. It resolves to false for all fields in the tester_ar project and the self.filter(connection) is never executed.

Commenting it out allows DRIVER=ar DEBUG=true bundle exec rspec to pass and relationship to be generated.

@maxcoto
Copy link
Owner

maxcoto commented Nov 26, 2019

@ostrgard thank you very much for using this gem, it makes me really happy. Feel free to send a PR if you find the solution to the ruby-graphql version upgrade. Unfortunately I stopped using this gem because of lack of support/usage, and that resolves in no maintenance from my side.

@maxcoto
Copy link
Owner

maxcoto commented Dec 12, 2019

@ostrgard I've been trying to upgrade to graphql1.9, here are the results:
One bug was that the gem was not lazy-loading model types.
Then as you mention the order of the include matter so they will have to be inserted at the bottom (I don't like this).

I am leaving the progress in a different branch because it seems to be working when there is only one worker in the puma.rb server configuration file. But when there is more than one, like:
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
it stops bringing the associations between models.
I've been trying to find the root of this problem without luck.

I think I will try a different way of loading the gem as a next step, by declaring the models in the config file instead of including concerns.

Any ideas ? 😄

#18

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

2 participants