I wanna set a default global callback in trpc.
For example, i can has a default error alert tip if we throw error in request, or we have take mutation show operate success alert tip.
Now, i have to set those in every where.
I take a look of source code, its weird:
getMutationDefaults
rather than getDefaultOptions
?__useMutation
options?mutationSuccessOverride
, why the overrides
handler is higher priority than options callback in caller where define as originalFn
?trpc/packages/react-query/src/shared/hooks/createHooksInternal.tsx
Lines 338 to 370 in 42e6910
Set in trpc.createTRPCReact
export const trpc = createTRPCReact<AppRouter>({
overrides: {
useMutation: {
onSuccess: ()=> console.log('success'),
},
},
});
or in new QueryClient
export const queryClient = new QueryClient({
defaultOptions: {
mutations: {
onSuccess: () => console.log('success'),
onError: () => console.log('error'),
},
},
});
none
I want to contribute code to implement this feature, but i cant understand why there logic is it.
I'm not sure if this is intentional, can you give me some context?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too