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

Per request cache? #74

Closed
raysuelzer opened this issue Sep 24, 2021 · 1 comment
Closed

Per request cache? #74

raysuelzer opened this issue Sep 24, 2021 · 1 comment

Comments

@raysuelzer
Copy link

Forgive me if this is out of scope, or I am missing something here. The problem I am seeking to solve is let's say you have 50 people in a list, and they all have the same creator. The current Ruby GraphQL gem will call resolve and serialze the response 50 times. I've been playing around with this gem a bit and don't notice any difference at all in the performance of caching the result. But, I am also concerned because I don't really want to cache the result after the current request ends, because the data might change and I don't want to have to deal with cache invalidation. I was hoping this gem would allow me to resolve creator (and serialize it, which is where ruby_graphql seems to spend the most time) once.


people {
   id
   creator {
     id
     email
   }
}
@DmitryTsepelev
Copy link
Owner

Hi @raysuelzer! Since you don't want to share cache between requests, you can use batch-loader—it's used to fix N+1 but looks like it should work for your case too: load the user once for all.

Closing the issue since it's out of scope of the gem but feel free to reach out if you need any help with GQL 🙂

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