tooot/src/utils/queryHooks/index.ts

19 lines
428 B
TypeScript
Raw Normal View History

import { QueryClient } from '@tanstack/react-query'
2021-05-12 15:40:55 +02:00
2023-01-09 19:18:48 +01:00
export const globalRetry = (failureCount: number) => failureCount <= 2
2023-01-03 23:57:23 +01:00
export const queryClient = new QueryClient({
2022-12-20 00:45:53 +01:00
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5,
retry: (failureCount, error: any) => {
2023-01-06 01:08:27 +01:00
if ([401, 404].includes(error?.status)) {
2022-12-20 00:45:53 +01:00
return false
}
2023-01-09 19:18:48 +01:00
return globalRetry(failureCount)
2022-12-20 00:45:53 +01:00
}
}
}
})