Closed tjvc closed 4 years ago
Hey @tjvc,
Interesting. A few questions:
use BatchLoader::GraphQL
in your schema?BatchLoader
and GraphQL
versions do you use?Hey @exAspArk. Thanks for the suggestion to try reproducing this in a smaller repo. I tried in a new application and couldn't. Digging into this a bit more, I discovered that it was related to our Pundit integration with GraphQL::Pro, and specifically the chaining of policy scopes onto batch-loaded relations, which triggered fresh queries. So I'll close this now as it's definitely not an issue with BatchLoader. Thanks for your time!
Nice gem - thanks!
This isn't an issue per se - I already have a working solution based on the second example from this section in the README: https://github.com/exAspArk/batch-loader#loading-multiple-items.
I'm curious though as to why the following approach does not prevent an N+1 query.
Given these models:
And a GraphQL schema with a
postsConnection
on the root query type and acommentsConnection
on thepost
type.The following seems to trigger an N+1 query for the comments association on each post when used to resolve the
commentsConnection
for eachpost
: