2026-04-14 21:26:00 -07:00
|
|
|
import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";
|
|
|
|
|
import { showErrorToast } from "../error-toast";
|
2025-11-11 04:02:04 +02:00
|
|
|
|
2026-02-28 01:54:54 -08:00
|
|
|
export const queryClient = new QueryClient({
|
|
|
|
|
defaultOptions: {
|
|
|
|
|
queries: {
|
|
|
|
|
staleTime: 30_000,
|
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-14 21:26:00 -07:00
|
|
|
queryCache: new QueryCache({
|
|
|
|
|
onError: (error, query) => {
|
|
|
|
|
if (query.meta?.suppressGlobalErrorToast) return;
|
|
|
|
|
showErrorToast(error);
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
mutationCache: new MutationCache({
|
|
|
|
|
onError: (error, _variables, _context, mutation) => {
|
|
|
|
|
if (mutation.meta?.suppressGlobalErrorToast) return;
|
|
|
|
|
showErrorToast(error);
|
|
|
|
|
},
|
|
|
|
|
}),
|
2026-02-28 01:54:54 -08:00
|
|
|
});
|