Skip to content

Commit

Permalink
Pass down the full operationOptions to the execute method
Browse files Browse the repository at this point in the history
  • Loading branch information
paales committed Oct 28, 2024
1 parent c1fa10f commit 659b322
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/react-hook-form/src/useFormGql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function useFormGql<Q, V extends FieldValues>(
document: TypedDocumentNode<Q, V>
form: UseFormReturn<V>
tuple: MutationTuple<Q, V> | LazyQueryResultTuple<Q, V>
operationOptions?: MutationHookOptions<Q, V>,
operationOptions?: MutationHookOptions<Q, V>
defaultValues?: UseFormProps<V>['defaultValues']
skipUnchanged?: boolean
} & UseFormGraphQLCallbacks<Q, V>,
Expand Down Expand Up @@ -184,9 +184,17 @@ export function useFormGql<Q, V extends FieldValues>(
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)
Expand Down

0 comments on commit 659b322

Please sign in to comment.