Using graphql-shield with data-loader #1526
Unanswered
MorganDavid
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, this library has been great so far, however I've run into a performance problem that is proving difficult to solve.
I have this type in my shield definition:
When I request 20 challenges, that db query gets ran (at least) 20 times. I have tried using data-loader in here, but the shield will not resolve all the rules in the type asynchronously (it always waits for one field to complete before evaluating the next). This means that the data-loader query always loads with only one key (so there's still lots of db queries).
for example, if I do this inside one of the rules,
I would expect something like:
but instead they appear synchronously (
graphql-middleware
logs them synchronously so I'm currently planning on putting the dataloaders in there and using context to pass them to shield rules)Is there some config I can change to make this work or is this a limitation of the library?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions