I have a question about how optimistic updates from mutations work with the onQueryUpdated callback.
I have a query that gets a list of items, and a mutation that creates a new item that belongs in that list. The mutation returns the new item in its response.
update callback I’m able to modify the cache directly to add the new item to the list. When the mutation response is received, my update callback is called, the cache is modified, then the onQueryUpdated callback is called, the original query is updated, and the new value is displayed. This works exactly as I’d expect.
However, if I specify an optimistic response from the mutation the update callback is now called twice (as I’d expect, once immediately based on the optimistic response, and a second time asynchronously when the actual response is received) but the onQueryUpdated callback is still only called once, after the actual response is received. This means that the new item is still not displayed in the list until after the actual response is received, whereas I would expect it to be rendered immediately based on the optimistic response.
Is this the expected behavior? If so, is there a recommended pattern for optimistically adding an item to a list to maintain a “live” UX?