I have a mutation set up to update a document.
I have a query in place on the same document.
What is currently happening:
Fire off the mutation.
Changes are reflected on Atlas.
Receive response from the mutation.
Query returns with expired data.
Why does the query come in with expired data after I’ve sent a mutation?
I’m 80% sure this was not happening a month ago. Did something change?
My UI updates based on the query signal, so every time I save a document, the UI is updating to the expired data, which is not consistent with the DB.
Could you please confirm my understanding of your issue-
You updated the document via a graphQL mutation
The updated data is visible on Atlas
You run a graphQL query on the same data
You received old data than the new one you updated to?
If my understanding is correct, it’s possible the query is returning cached data. Could you let us know how are you running the mutation/query? Are you using a client like Apollo?
The key to my solution ended up being here in the apollo docs.
In case it’s helpful for someone in the future, this is basically my code. I had to add a refetchQueries key when passing options to the mutation. Refer to the apollo docs for configuration details. I found it to be a little confusing figuring out how to reference the query that you want to be reloaded.