@@ -6,6 +6,7 @@ import type {
66 CreateMutateFunction ,
77 CreateMutationOptions ,
88 CreateMutationResult ,
9+ FunctionedParams ,
910} from './types'
1011
1112import type { DefaultError , QueryClient } from '@tanstack/query-core'
@@ -16,13 +17,18 @@ export function createMutation<
1617 TVariables = void ,
1718 TContext = unknown ,
1819> (
19- options : CreateMutationOptions < TData , TError , TVariables , TContext > ,
20+ options : FunctionedParams <
21+ CreateMutationOptions < TData , TError , TVariables , TContext >
22+ > ,
2023 queryClient ?: QueryClient ,
2124) : CreateMutationResult < TData , TError , TVariables , TContext > {
2225 const client = useQueryClient ( queryClient )
2326
2427 const observer = $derived (
25- new MutationObserver < TData , TError , TVariables , TContext > ( client , options ) ,
28+ new MutationObserver < TData , TError , TVariables , TContext > (
29+ client ,
30+ options ( ) ,
31+ ) ,
2632 )
2733 const mutate = $state <
2834 CreateMutateFunction < TData , TError , TVariables , TContext >
@@ -31,7 +37,7 @@ export function createMutation<
3137 } )
3238
3339 $effect . pre ( ( ) => {
34- observer . setOptions ( options )
40+ observer . setOptions ( options ( ) )
3541 } )
3642
3743 const result = $state ( observer . getCurrentResult ( ) )
0 commit comments