···11+---
22+'@urql/exchange-graphcache': patch
33+---
44+55+Set `stale: true` on cache results, even if a reexecution has been blocked by the loop protection, if the operation is already pending and in-flight.
···3232 noopDataState,
3333 hydrateData,
3434 reserveLayer,
3535+ hasLayer,
3536} from './store/data';
36373738interface OperationResultWithMeta extends Partial<OperationResult> {
···377378 (requestPolicy === 'cache-first' &&
378379 res.outcome === 'partial' &&
379380 !reexecutingOperations.has(res.operation.key)));
381381+ // Set stale to true anyway, even if the reexecute will be blocked, if the operation
382382+ // is in progress. We can be reasonably sure of that if a layer has been reserved for it.
383383+ const stale =
384384+ requestPolicy !== 'cache-only' &&
385385+ (shouldReexecute ||
386386+ (res.outcome === 'partial' &&
387387+ reexecutingOperations.has(res.operation.key) &&
388388+ hasLayer(store.data, res.operation.key)));
380389381390 const result: OperationResult = {
382391 operation: addMetadata(res.operation, {
···385394 data: res.data,
386395 error: res.error,
387396 extensions: res.extensions,
388388- stale: shouldReexecute && !res.hasNext,
397397+ stale: stale && !res.hasNext,
389398 hasNext: shouldReexecute && res.hasNext,
390399 };
391400
+5
exchanges/graphcache/src/store/data.ts
···528528 data.commutativeKeys.add(layerKey);
529529};
530530531531+/** Checks whether a given layer exists */
532532+export const hasLayer = (data: InMemoryData, layerKey: number) =>
533533+ data.commutativeKeys.has(layerKey) ||
534534+ data.optimisticOrder.indexOf(layerKey) > -1;
535535+531536/** Creates an optimistic layer of links and records */
532537const createLayer = (data: InMemoryData, layerKey: number) => {
533538 if (data.optimisticOrder.indexOf(layerKey) === -1) {