My React GraphQL implementation stopped working this week. After running a mutation, I’m getting query results containing old data.
My implementation allows for the creation and editing of records via GraphQL.
So I have a GraphQL query that returns data, and I update my view according to that data.
During editing, I ignore data coming from the query. When edits are saved, I fire off a mutation. When the mutation returns a response, I resume listening to the data coming from the query.
So, as soon as a user begins changing the input in the UI, I start ignoring any data that is coming from the GraphQL query. I do not stop ignoring this data until the user clicks ‘save’ in my UI, triggers a mutation, and that mutation returns.
This was working well until sometime last week I think. Now, after a mutation is sent and a response is received, the query then sends old data one last time.
So, effectively, I send the mutation to change the document. I get a response that says that the document has changed. I start listening to changes again that come from the query. The query sends me old data and I adjust my UI based on that. So my UI reverts to the state before the mutation was sent. I check the Atlas collection manually and it reflects the correct, updated state.
Did something change recently? Why would the query return old data after the mutation has been sent and a response has been received?