/** * React Query Configuration * Setup do QueryClient para cache e sincronização de dados * @version 1.0 */ import { QueryClient } from "@tanstack/react-query"; /** * Configuração padrão do QueryClient * - staleTime: 5 minutos - dados são considerados frescos por 5min * - cacheTime: 10 minutos - dados permanecem em cache por 10min após não serem usados * - retry: 3 tentativas com backoff exponencial * - refetchOnWindowFocus: false - não refetch automático ao focar janela */ export const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 5 * 60 * 1000, // 5 minutos gcTime: 10 * 60 * 1000, // 10 minutos (anteriormente cacheTime) retry: 3, retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000), refetchOnWindowFocus: false, refetchOnReconnect: true, }, mutations: { retry: 1, retryDelay: 1000, }, }, });