|
| 1 | +import { |
| 2 | + MutationFunction, |
| 3 | + MutationKey, |
| 4 | + UseMutationOptions, |
| 5 | + UseMutationResult, |
| 6 | + parseMutationArgs, |
| 7 | + useMutation as useMutation_, |
| 8 | +} from '@tanstack/react-query' |
| 9 | + |
| 10 | +import { queryClientContext as context } from '../../../context' |
| 11 | + |
| 12 | +export function useMutation< |
| 13 | + TData = unknown, |
| 14 | + TError = unknown, |
| 15 | + TVariables = void, |
| 16 | + TContext = unknown, |
| 17 | +>( |
| 18 | + options: UseMutationOptions<TData, TError, TVariables, TContext>, |
| 19 | +): UseMutationResult<TData, TError, TVariables, TContext> |
| 20 | + |
| 21 | +export function useMutation< |
| 22 | + TData = unknown, |
| 23 | + TError = unknown, |
| 24 | + TVariables = void, |
| 25 | + TContext = unknown, |
| 26 | +>( |
| 27 | + mutationFn: MutationFunction<TData, TVariables>, |
| 28 | + options?: Omit< |
| 29 | + UseMutationOptions<TData, TError, TVariables, TContext>, |
| 30 | + 'mutationFn' |
| 31 | + >, |
| 32 | +): UseMutationResult<TData, TError, TVariables, TContext> |
| 33 | + |
| 34 | +export function useMutation< |
| 35 | + TData = unknown, |
| 36 | + TError = unknown, |
| 37 | + TVariables = void, |
| 38 | + TContext = unknown, |
| 39 | +>( |
| 40 | + mutationKey: MutationKey, |
| 41 | + options?: Omit< |
| 42 | + UseMutationOptions<TData, TError, TVariables, TContext>, |
| 43 | + 'mutationKey' |
| 44 | + >, |
| 45 | +): UseMutationResult<TData, TError, TVariables, TContext> |
| 46 | + |
| 47 | +export function useMutation< |
| 48 | + TData = unknown, |
| 49 | + TError = unknown, |
| 50 | + TVariables = void, |
| 51 | + TContext = unknown, |
| 52 | +>( |
| 53 | + mutationKey: MutationKey, |
| 54 | + mutationFn?: MutationFunction<TData, TVariables>, |
| 55 | + options?: Omit< |
| 56 | + UseMutationOptions<TData, TError, TVariables, TContext>, |
| 57 | + 'mutationKey' | 'mutationFn' |
| 58 | + >, |
| 59 | +): UseMutationResult<TData, TError, TVariables, TContext> |
| 60 | + |
| 61 | +export function useMutation< |
| 62 | + TData = unknown, |
| 63 | + TError = unknown, |
| 64 | + TVariables = void, |
| 65 | + TContext = unknown, |
| 66 | +>( |
| 67 | + arg1: |
| 68 | + | MutationKey |
| 69 | + | MutationFunction<TData, TVariables> |
| 70 | + | UseMutationOptions<TData, TError, TVariables, TContext>, |
| 71 | + arg2?: |
| 72 | + | MutationFunction<TData, TVariables> |
| 73 | + | UseMutationOptions<TData, TError, TVariables, TContext>, |
| 74 | + arg3?: UseMutationOptions<TData, TError, TVariables, TContext>, |
| 75 | +): UseMutationResult<TData, TError, TVariables, TContext> { |
| 76 | + const options = parseMutationArgs(arg1, arg2, arg3) |
| 77 | + return useMutation_({ context, ...options }) |
| 78 | +} |
0 commit comments