Open lensbart opened 5 years ago
I'm seeing the same thing in a small project I'm doing on the side. I can give more details and steps to reproduce as well if it's helpful, but I just wanted to 1+ this.
+1 this, can also be reproduced in my project.
Hello homies,
When executing a remote mutation with an optimistic response, the optimistic data is not available via
cache.readQuery
in the resolver of another local mutation that’s run in quick succession afterwards.The problem occurs reproducibly in the following sequence of steps:
useEffect
oruseLayoutEffect
By contrast, the actual server response (2nd time the
update
function of the remote mutationremoteMutation
is run) is available in the local mutation resolver.I checked to confirm that the store got updated correctly, by checking the value of
cache.readQuery
immediately after writing to the store in the update function of the remote mutation (at the position of the comment// (*)
above). Here, I could see the optimistic response data in the Apollo store.I ensured that none of my mutations are mutating variables (see https://github.com/apollographql/react-apollo/issues/3290 for the description of an identical problem). To be extra sure, I wrapped the
data
passed tocache.writeQuery
inclone()
from Ramda, a utility library, to the same effect.Thanks in advance for your insight and help!