From 659b322957a1b7bb6a6475c2dbb6a2b40196c41e Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Mon, 28 Oct 2024 09:52:07 +0100 Subject: [PATCH] Pass down the full operationOptions to the execute method --- packages/react-hook-form/src/useFormGql.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/react-hook-form/src/useFormGql.tsx b/packages/react-hook-form/src/useFormGql.tsx index 5c1251e815..9b7894da0b 100644 --- a/packages/react-hook-form/src/useFormGql.tsx +++ b/packages/react-hook-form/src/useFormGql.tsx @@ -99,7 +99,7 @@ export function useFormGql( document: TypedDocumentNode form: UseFormReturn tuple: MutationTuple | LazyQueryResultTuple - operationOptions?: MutationHookOptions, + operationOptions?: MutationHookOptions defaultValues?: UseFormProps['defaultValues'] skipUnchanged?: boolean } & UseFormGraphQLCallbacks, @@ -184,9 +184,17 @@ export function useFormGql( submittedVariables.current = variables if (!deprecated_useV1 && loading) controllerRef.current?.abort() controllerRef.current = new window.AbortController() + const result = await execute({ variables, - context: { fetchOptions: { signal: controllerRef.current.signal }, ...operationOptions?.context}, + ...operationOptions, + context: { + ...operationOptions?.context, + fetchOptions: { + ...operationOptions?.context?.fetchOptions, + signal: controllerRef.current.signal, + }, + }, }) const [, onCompleteError] = await complete(result, variables)