File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { Removable } from './removable'
3
3
import { createRetryer } from './retryer'
4
4
import type {
5
5
DefaultError ,
6
+ MutationFunctionContext ,
6
7
MutationMeta ,
7
8
MutationOptions ,
8
9
MutationStatus ,
@@ -167,7 +168,11 @@ export class Mutation<
167
168
if ( ! this . options . mutationFn ) {
168
169
return Promise . reject ( new Error ( 'No mutationFn found' ) )
169
170
}
170
- return this . options . mutationFn ( variables )
171
+ const mutationFnContext : MutationFunctionContext = {
172
+ mutationKey : this . options . mutationKey ,
173
+ meta : this . meta ,
174
+ }
175
+ return this . options . mutationFn ( variables , mutationFnContext )
171
176
} ,
172
177
onFail : ( failureCount , error ) => {
173
178
this . #dispatch( { type : 'failed' , failureCount, error } )
Original file line number Diff line number Diff line change @@ -888,8 +888,14 @@ export type MutationMeta = Register extends {
888
888
: Record < string , unknown >
889
889
: Record < string , unknown >
890
890
891
+ export type MutationFunctionContext = {
892
+ mutationKey ?: MutationKey
893
+ meta : MutationMeta | undefined
894
+ }
895
+
891
896
export type MutationFunction < TData = unknown , TVariables = unknown > = (
892
897
variables : TVariables ,
898
+ context : MutationFunctionContext ,
893
899
) => Promise < TData >
894
900
895
901
export interface MutationOptions <
You can’t perform that action at this time.
0 commit comments