♻️ Improve query invalidation (#659)

This commit is contained in:
Luke Vella 2023-04-08 12:43:54 +01:00 committed by GitHub
parent 0ad5abb590
commit 5b6d8424af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 26 deletions

View file

@ -9,21 +9,6 @@ import { AppRouter } from "../../trpc/routers";
export * from "../../trpc/types";
export const trpc = createTRPCNext<AppRouter>({
unstable_overrides: {
useMutation: {
async onSuccess(opts) {
/**
* @note that order here matters:
* The order here allows route changes in `onSuccess` without
* having a flash of content change whilst redirecting.
**/
await opts.originalFn();
if (!opts.meta?.doNotInvalidate) {
await opts.queryClient.invalidateQueries();
}
},
},
},
config() {
return {
links: [