Replies: 1 comment 2 replies
-
I don't think I fully understand the question. How would a mutation key per mutate call solve the problem? can you show some example code? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know this is related to several discussions, but I didn't see one for this precise feature. I really would like it if I could set a cache key per mutate() call. I would like to be able to use filters to retrieve all cached
useAddThing().mutate()
results, for instance. This would help do a "half-optimistic" update, where we show a new thing as soon as we know the server accepted it, but before a refetch finishes (some of my fetches are slow).I don't like the common solution of editing the cached result of a getThings() query (my server data is sacred, dangnabbit!), or imperatively adding arbitrary keys to the cache, which just feels like doing local state operations but in the wrong place. I am instead using local state to store mutation results, which feels like the best of bad options but counter- to the goal of react-query. Especially when an idiomatic solution feels so close.
Beta Was this translation helpful? Give feedback.
All reactions