how to update cache after a query #1784
-
thanks ! inside a post query, i also updated /mutated user model so i am doing both Query/mutation in one graphql I can split the query and make a mutation for the update , but it means that I need to sent two request instead of just Get Post and update user model together in one graphql query after the Query , I would like to optimistically update the history cache after issuing a get post query, how can I do it ? :( tried resolver but didn't work out, even though the query response is there, useQuery didn't get it, not sure if cache was mutated too.
should I split the logic into two graphql request so that I can use updates not resolvers also is it a good idea to do both mutation/query in one Query ? to save number of query needed ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
it's never a good idea to add side-effects and updates of any kind to queries. They're repeatable and fetch data without changing anything, so they're not meant for updates |
Beta Was this translation helpful? Give feedback.
it's never a good idea to add side-effects and updates of any kind to queries. They're repeatable and fetch data without changing anything, so they're not meant for updates