Skip to content

Commit

Permalink
Mutate operation.context directly since persistedFetchExchange is ter…
Browse files Browse the repository at this point in the history
…minating
  • Loading branch information
kitten committed Mar 15, 2023
1 parent 1dcd431 commit cf425fe
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions exchanges/persisted-fetch/src/persistedFetchExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
takeUntil,
} from 'wonka';

import {
makeOperation,
import type {
CombinedError,
ExchangeInput,
Exchange,
Expand Down Expand Up @@ -154,27 +153,24 @@ const makePersistedFetchSource = (
dispatchDebug: ExchangeInput['dispatchDebug'],
useGet: boolean
): Source<OperationResult> => {
const newOperation = makeOperation(operation.kind, operation, {
...operation.context,
preferGetMethod: useGet ? 'force' : operation.context.preferGetMethod,
});
if (useGet) operation.context.preferGetMethod = 'force';

const url = makeFetchURL(newOperation, body);
const fetchOptions = makeFetchOptions(newOperation, body);
const url = makeFetchURL(operation, body);
const fetchOptions = makeFetchOptions(operation, body);

dispatchDebug({
type: 'fetchRequest',
message: !body.query
? 'A fetch request for a persisted query is being executed.'
: 'A fetch request is being executed.',
operation: newOperation,
operation,
data: {
url,
fetchOptions,
},
});

let fetch$ = makeFetchSource(newOperation, url, fetchOptions);
let fetch$ = makeFetchSource(operation, url, fetchOptions);

if (process.env.NODE_ENV !== 'production') {
fetch$ = pipe(
Expand Down

0 comments on commit cf425fe

Please sign in to comment.