diff --git a/src/useMutation.ts b/src/useMutation.ts index a755ee0..adade8b 100644 --- a/src/useMutation.ts +++ b/src/useMutation.ts @@ -130,7 +130,10 @@ export function useMutation( }; const runMutation = React.useCallback( - (mutateOptions: MutationHookOptions = {}) => { + ( + mutateOptions: MutationHookOptions = {}, + context: TData | undefined + ) => { return new Promise>((resolve, reject) => { onMutationStart(); const mutationId = generateNewMutationId(); @@ -149,11 +152,11 @@ export function useMutation( variables: mutateVariables, }) .then(response => { - onMutationCompleted(response, mutationId); + onMutationCompleted(response, mutationId, context); resolve(response as ExecutionResult); }) .catch(err => { - onMutationError(err, mutationId); + onMutationError(err, mutationId, context); if (rethrow) { reject(err); return;