-
Notifications
You must be signed in to change notification settings - Fork 36
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
is apollo client next compatible with unstable cache? #250
Comments
That's a very broad question. What would you want to use it for? Generally, Apollo Client will do normal |
You can't use on demand revalidation with this Apollo Client. So my idea was to use unstable_cache with apollo client (no cache) to cache the results (because I want to use query batching too) But i ran into a problem, that is if a disable the cache of the fetch used in apollo, the entire route is gonna change to dynamic route (and I don't want) |
@niloodev I think you might be mixing up some things here: in RSC, we create a new instance of Apollo Client for every incoming request and these start with an empty cache, so all kind of caching beyond "while a request is happening" is the job of your framework's HTTP caching layer. If you can use "on demand revalidation" without Apollo Client, I would assume that you can use it with Apollo Client as well. If you're experiencing the opposite, could you share some code so we can see what you are trying to do here? |
@phryneas Basically I want to use Next on-demand-revalidation with query batching. I have an application that fetches many data from the same source (Wordpress) using GraphQL, the problem is: I can't predict how the query is gonna be, because I'm using query batching (and I have many different queries with different tags), so my idea was to use unstable_cache to make the cache layer above Apollo, that way I won't necessarily cache the requests, but the results. But this leave me to many issues, and one of them is Next detecting that Apollo Client is using a dynamic fetch, and changing the entire route to dynamic. I can't paste the code since it is from my job, but it would be awesome if you could help me with this. (And yes, query batching in my application would be the perfect solution, but this kinda makes me HAVE to use Apollo Client since its the best GraphQL client with that functionality). |
@niloodev For that use case, I'd actually suggest to disable query batching on the server (you can still enable it in the browser). It will give you a lot of benefits in the browser, but in RSC, you will have a much better time with Vercel's |
@phryneas Okay I will do that, thank you for the help! |
hey @phryneas what is the correct way to handle fetchOptions per requests basis from a RSC? Maybe pass this as a parameter for every requests? The readme shows a |
@yanv1991 you'd do const { data } = await query({
query: QUERY,
context: { fetchOptions: { cache: "no-store" } },
}); |
closing this ticket since this was solved, thanks! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Just wondering if we can use apollo client next + unstable cache in a RSC, if not, what alternatives could we consider to cache data in the server?
The text was updated successfully, but these errors were encountered: