Optimistic Updates With GraphQL #3545
-
I'm implementing optimistic updates for an app that is using a GraphQL API and I'm finding it to be much more involved than I was expecting which is making me think there has to be a better approach. The main problem is that in order to optimistically update the cache, I need to know not only each query that the update needs to patch, but also all the arguments for those queries. For example, imagine I have a Additionally, having to 'know' about which queries to patch seems like something that is duplicating the use of tags to provide and invalidate data. What am I missing here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
RTKQ works by serializing the arguments so it can generate the cache key, like Hypothetically, how would you expect to be able to update individual cache entries without knowing the way to look them up? |
Beta Was this translation helpful? Give feedback.
It can cache GraphQL requests, but we are very upfront that it is a document cache, not a normalized cache.
At this rate, RTK Query is about the level of
urql
without their optional Graphcache - no normalization, the only good way of updating data is automatic invalidation. That's okay for smaller apps, but not for advanced use of GraphQL.