graphCache not working as expected #1441
-
We are trying to move over to graphCache from the default document-cache in order to reduce the amount of fetches caused when we have mutations. What we are trying to establish right now, is if it will actually fix this issue or if there's an alternative way. At the moment we have a list of authors with a list of their respective books and inside each book are the pages. We make a query for the list of authors, then a separate query for the book and pages per author which all sit inside a separate component. If we delete a page from a book, all books for all authors appear to be refetched and the book components re-rendered. This we understood to be a constraint of document-caching. However, we are now attempting to resolve this by using graph-cache and invalidating the individual books so only theirs are refetched. So far we still appear to be re-rendering all book components for all authors and refetching them. Is this normal or have we made a mistake with the cache.invalidation? our cache invalidation
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Hey, This is a side-effect of not knowing what the author.books array contains as a type, let's look at how this works. When we invalidate the book this book becomes So invalidate won't work for this particular case, a better solution for this specific case would be to get the affected entity in question and update its array with updateQuery. |
Beta Was this translation helpful? Give feedback.
Hey,
This is a side-effect of not knowing what the author.books array contains as a type, let's look at how this works.
When we invalidate the book this book becomes
['Book:1', null]
as we have invalidatedBook:2
, if your author.books type is[Book]!
we can safely render the partial data (requires schema-awareness) if it's[Book!]!
we can't safely render partial data.So invalidate won't work for this particular case, a better solution for this specific case would be to get the affected entity in question and update its array with updateQuery.