Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(graphcache): Prevent offlineExchange from issuing duplicate operations (#3200)

authored by

Phil Pluckthun and committed by
GitHub
89b5f8cc 75b0d7ca

+13 -3
+5
.changeset/hungry-zebras-count.md
··· 1 + --- 2 + '@urql/exchange-graphcache': patch 3 + --- 4 + 5 + Prevent `offlineExchange` from issuing duplicate operations.
+8 -3
exchanges/graphcache/src/offlineExchange.ts
··· 151 151 const flushQueue = () => { 152 152 if (!isFlushingQueue) { 153 153 isFlushingQueue = true; 154 + 155 + const sent = new Set<number>(); 154 156 for (let i = 0; i < failedQueue.length; i++) { 155 157 const operation = failedQueue[i]; 156 - if (operation.kind === 'mutation') 157 - next(makeOperation('teardown', operation)); 158 - next(operation); 158 + if (operation.kind === 'mutation' || !sent.has(operation.key)) { 159 + if (operation.kind !== 'subscription') 160 + next(makeOperation('teardown', operation)); 161 + sent.add(operation.key); 162 + next(toRequestPolicy(operation, 'cache-first')); 163 + } 159 164 } 160 165 161 166 failedQueue.length = 0;