···11+---
22+'@urql/exchange-graphcache': patch
33+---
44+55+Allow `offlineExchange` to once again issue all request policies, instead of mapping them to `cache-first`. When replaying operations after rehydrating it will now prioritise network policies, and before rehydrating receiving a network result will prevent a network request from being issued again.
+6
.changeset/two-ants-relate.md
···11+---
22+'@urql/exchange-graphcache': patch
33+'@urql/core': patch
44+---
55+66+Add `OperationContext.optimistic` flag as an internal indication on whether a mutation triggered an optimistic update in `@urql/exchange-graphcache`'s `cacheExchange`.
+7-1
exchanges/graphcache/src/cacheExchange.ts
···44 makeOperation,
55 Operation,
66 OperationResult,
77+ OperationContext,
78 RequestPolicy,
89 CacheOutcome,
910} from '@urql/core';
···144145145146 // This registers queries with the data layer to ensure commutativity
146147 const prepareForwardedOperation = (operation: Operation) => {
148148+ let context: Partial<OperationContext> | undefined;
147149 if (operation.kind === 'query') {
148150 // Pre-reserve the position of the result layer
149151 reserveLayer(store.data, operation.key);
···155157 reexecutingOperations.delete(operation.key);
156158 // Mark operation layer as done
157159 noopDataState(store.data, operation.key);
160160+ return operation;
158161 } else if (
159162 operation.kind === 'mutation' &&
160163 operation.context.requestPolicy !== 'network-only'
···175178 const pendingOperations: Operations = new Set();
176179 collectPendingOperations(pendingOperations, dependencies);
177180 executePendingOperations(operation, pendingOperations, true);
181181+182182+ // Mark operation as optimistic
183183+ context = { optimistic: true };
178184 }
179185 }
180186···190196 )
191197 : operation.variables,
192198 },
193193- operation.context
199199+ { ...operation.context, ...context }
194200 );
195201 };
196202
···528528 * @see {@link https://beta.reactjs.org/blog/2022/03/29/react-v18#new-suspense-features} for more information on React Suspense.
529529 */
530530 suspense?: boolean;
531531+ /** A metdata flag indicating whether this operation triggered optimistic updates.
532532+ *
533533+ * @remarks
534534+ * This configuration flag is reserved for `@urql/exchange-graphcache` and is flipped
535535+ * when an operation triggerd optimistic updates.
536536+ */
537537+ optimistic?: boolean;
531538 [key: string]: any;
532539}
533540