Apollo client & NextJS app router
Answered
Dogue Brasileiro posted this in #help-forum
Dogue BrasileiroOP
I'm experiencing issues with Apollo Client and the NextJS app router related to caching. Does anyone here have expertise with caching in this context?
The problem might be specific to NextJS, but I'm not entirely sure.
I have a query that fetches the contents of a cart. When users navigate to the /cart route, the data isn't cached (which is correct). However, if the page is refreshed, nested objects within the cart items are cached (not correct). I think this is a normalization cache of some sort, but cannot figure out how to disable it.
For instance, here's a sample of the data:
{
"name": "Product name", // not cached
"data": {
"color": "red" // cached
}
}It seems the cache is only hit upon a page refresh, not when navigating to the route. Any insights would be appreciated!
The problem might be specific to NextJS, but I'm not entirely sure.
I have a query that fetches the contents of a cart. When users navigate to the /cart route, the data isn't cached (which is correct). However, if the page is refreshed, nested objects within the cart items are cached (not correct). I think this is a normalization cache of some sort, but cannot figure out how to disable it.
For instance, here's a sample of the data:
{
"name": "Product name", // not cached
"data": {
"color": "red" // cached
}
}It seems the cache is only hit upon a page refresh, not when navigating to the route. Any insights would be appreciated!
Answered by Dogue Brasileiro
I got it fixed, but I dont know why. Wrapping the client component in Suspense corrected it. Even tho everything is Clientside and there is no promise in the child component
1 Reply
Dogue BrasileiroOP
I got it fixed, but I dont know why. Wrapping the client component in Suspense corrected it. Even tho everything is Clientside and there is no promise in the child component
Answer