-
Notifications
You must be signed in to change notification settings - Fork 52
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
Best Practice Using Batch loader on Graphql 1.8.11 #30
Comments
Hi @im-not-a-robot! Did you add It should work without batch-loader/spec/graphql_spec.rb Lines 4 to 28 in a726994
|
Yes im already add May if you want to see the issue, i can send you the project. |
@im-not-a-robot yes, please 🙏 If you can send me the project (e.g. a github repo), that'll save me some time. |
Hi, you can get it here : |
Hello, Currently having the same problem above and the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Hello @exAspArk |
Looking into it now |
@im-not-a-robot unfortunately, I couldn't run your rails example app. Something is wrong with a DB: partially pg, partially sqlite, no migrations, no seed data, etc. I created a new very basic Rails app which should be relatively simple to run https://github.com/exAspArk/batch-loader-graphql. I use Please let me know if you can reproduce it with that rails app. Maybe the latest |
@exAspArk Sorry for the problem. I'm already update the project, please check it again. Thank you.
|
@im-not-a-robot awesome, thank you! Could you please try these changes: # Gemfile
gem 'batch-loader', github: 'exAspArk/batch-loader', branch: 'graphql' You'd need to replace class PostType < GraphQL::Schema::Object
field :user, UserType, null: false
def user
BatchLoader::GraphQL.for(object.user_id).batch do |user_ids, loader|
User.where(id: user_ids).each { |user| loader.call(user.id, user) }
end
end
end I will write more details on the issue later. |
Yeah its works well. Thank you ! |
@im-not-a-robot perfect, thank you! I wrote an explanation about the root cause in #32. Will try to ship it tomorrow. |
Released these changes in
|
My code for batch loader :
Result :
Here's my gemfile :
Im already use your quick fix on this comment
#22 (comment)
It can solved this problem.
The other solution :
rmosolgo/graphql-ruby#1778 (comment)
But it must make scope attribute to false
Is there best practice to solve this problem ?
Thank you
The text was updated successfully, but these errors were encountered: