-
Hello everyone, I'm working with an API that provides endpoints for mutations that also send back the new state of the mutated entity as the response. While the regular flow of invalidating the cache works just fine, I'm wondering it it's possible to combine a mutation with a query. Let's say I have a query for a Product, with a tag (of type Currently mutations can't provide tags. Is this something that's planned, or should I look into something like the optimistic updates? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
That wouldn't change anything with your problem I think. If you want to use the return value from your mutation to update cache values for queries, you are correct that you can use the same mechanisms you'd use for optimistic updates for that. You'd just wait for the result and then use the result value to update the cache value of your query, instead of doing it at query initialization and rolling back on error. |
Beta Was this translation helpful? Give feedback.
That wouldn't change anything with your problem I think.
That something "provides a tag" only means that it will be re-fetched if that tag is invalidated - a tag is only an indicator to the system to trigger a re-fetch, not holding any data. Since we assume that sending a mutation actually initiates a change in the database on the server, we will never do that automatically - that always has to be implicit. (If your mutation only fetches data without triggering a change in the backend, it should just not be a mutation, but a query.)
If you want to use th…