1import type { Operation, RequestPolicy, OperationDebugMeta } from '@urql/core';
2import { makeOperation } from '@urql/core';
3
4// Returns the given operation result with added cacheOutcome meta field
5export const addMetadata = (
6 operation: Operation,
7 meta: OperationDebugMeta
8): Operation =>
9 makeOperation(operation.kind, operation, {
10 ...operation.context,
11 meta: {
12 ...operation.context.meta,
13 ...meta,
14 },
15 });
16
17// Copy an operation and change the requestPolicy to skip the cache
18export const toRequestPolicy = (
19 operation: Operation,
20 requestPolicy: RequestPolicy
21): Operation => {
22 return makeOperation(operation.kind, operation, {
23 ...operation.context,
24 requestPolicy,
25 });
26};