Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code incompatible from 5.14.6 to 5.17.9 of @tanstack/react-query #48

Open
yangricardo opened this issue Jan 11, 2024 · 1 comment

Comments

@yangricardo
Copy link

yangricardo commented Jan 11, 2024

Today when i have updated the @tanstack/react-query depenency, i found out that the latest compatible version is 5.13.4.

Changing the generated local code from:

ts function useRapiniMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, config?: (queryClient: QueryClient) => Pick<UseMutationOptions<TData, TError, TVariables, TContext>, "onSuccess" | "onSettled" | "onError">, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">): UseMutationResult<TData, TError, TVariables, TContext> { const { onSuccess, onError, onSettled, ...rest } = options ?? {}; const queryClient = useQueryClient(); const conf = config?.(queryClient); const mutationOptions: typeof options = { onSuccess: (data: TData, variables: TVariables, context?: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); }, onError: (error: TError, variables: TVariables, context?: TContext) => { conf?.onError?.(error, variables, context); onError?.(error, variables, context); }, onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context?: TContext) => { conf?.onSettled?.(data, error, variables, context); onSettled?.(data, error, variables, context); }, ...rest }; return useMutation({ mutationFn, ...mutationOptions }); }

to

ts function useRapiniMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, config?: (queryClient: QueryClient) => Pick<UseMutationOptions<TData, TError, TVariables, TContext>, "onSuccess" | "onSettled" | "onError">, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">): UseMutationResult<TData, TError, TVariables, TContext> { const { onSuccess, onError, onSettled, ...rest } = options ?? {}; const queryClient = useQueryClient(); const conf = config?.(queryClient); const mutationOptions: typeof options = { onSuccess: (data: TData, variables: TVariables, context: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); }, onError: (error: TError, variables: TVariables, context?: TContext) => { conf?.onError?.(error, variables, context); onError?.(error, variables, context); }, onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context?: TContext) => { conf?.onSettled?.(data, error, variables, context); onSettled?.(data, error, variables, context); }, ...rest }; return useMutation({ mutationFn, ...mutationOptions }); }

makes it compile again:

onSuccess: (data: TData, variables: TVariables, context: TContext) => {
conf?.onSuccess?.(data, variables, context);
onSuccess?.(data, variables, context);
},

@rametta
Copy link
Owner

rametta commented Jan 19, 2024

Hey @yangricardo, thanks for opening the issue. I won't have much time for awhile to look into this, but if you or anyone else wants to open a PR, I will gladly review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants