Optimistic updates not updating cache as expected #1645
-
Hi, I'm applying the following optimistic configuration in the cacheexchange then re-executing my query on completion (with cache-only setting) but it doesn't seem to be updating the cache at all.
I've also tried adding a writeFragment config to the updates like so but it makes no difference:
I'm wondering what I'm missing here to be able to make this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Most of the time this is because your optimistic configuration there is missing some data and a subsequent query then experiences a cache miss that can only be resolved once the mutation completes. Internally it'll basically try to fetch data from the API, but will then be forced to wait until the mutation completes. We currently don't have a warning for this because it's a little tricky to detect automatically. But if you look at the urql devtools you should actually see the cache miss come up. To me it's actually looking like You're also right in that writing an updater shouldn't be needed. In fact, in this case your updater won't do anything additionally to your optimistic function. |
Beta Was this translation helpful? Give feedback.
Most of the time this is because your optimistic configuration there is missing some data and a subsequent query then experiences a cache miss that can only be resolved once the mutation completes. Internally it'll basically try to fetch data from the API, but will then be forced to wait until the mutation completes. We currently don't have a warning for this because it's a little tricky to detect automatically.
But if you look at the urql devtools you should actually see the cache miss come up.
To me it's actually looking like
active_mnemonic
is missing a__typename
property. That being said, it can have various causes depending on what fields your queries will need to have available.Yo…