···11+---
22+'@urql/exchange-graphcache': patch
33+---
44+55+Retry operations against offline cache and stabilize timing of flushing failed operations queue after rehydrating the storage data.
+1
exchanges/graphcache/src/cacheExchange.ts
···7171 const store = new Store<C>(opts);
72727373 if (opts && opts.storage) {
7474+ store.data.hydrating = true;
7475 opts.storage.readData().then(entries => {
7576 hydrateData(store.data, opts!.storage!, entries);
7677 });
···3131}
32323333export interface InMemoryData {
3434+ /** Flag for whether the data is waiting for hydration */
3535+ hydrating: boolean;
3436 /** Flag for whether deferred tasks have been scheduled yet */
3537 defer: boolean;
3638 /** A list of entities that have been flagged for gargabe collection since no references to them are left */
···109111 // We don't create new layers for read operations and instead simply
110112 // apply the currently available layer, if any
111113 currentOptimisticKey = layerKey;
112112- } else if (isOptimistic || data.optimisticOrder.length > 1) {
114114+ } else if (
115115+ isOptimistic ||
116116+ data.hydrating ||
117117+ data.optimisticOrder.length > 1
118118+ ) {
113119 // If this operation isn't optimistic and we see it for the first time,
114120 // then it must've been optimistic in the past, so we can proactively
115121 // clear the optimistic data before writing
···155161 currentOptimisticKey = null;
156162157163 // Determine whether the current operation has been a commutative layer
158158- if (layerKey && data.optimisticOrder.indexOf(layerKey) > -1) {
164164+ if (
165165+ !data.hydrating &&
166166+ layerKey &&
167167+ data.optimisticOrder.indexOf(layerKey) > -1
168168+ ) {
159169 // Squash all layers in reverse order (low priority upwards) that have
160170 // been written already
161171 let i = data.optimisticOrder.length;
···217227};
218228219229export const make = (queryRootKey: string): InMemoryData => ({
230230+ hydrating: false,
220231 defer: false,
221232 gc: new Set(),
222233 persist: new Set(),
···634645 }
635646 }
636647648648+ data.storage = storage;
649649+ data.hydrating = false;
637650 clearDataState();
638638- data.storage = storage;
639651};