Bin
2025-12-17 2b99d77d73ba568beff0a549534017caaad8a6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { QueryClient as QC } from "@tanstack/react-query";
 
/**
 * Allows for e2e testing without cache if user is from e2e domain
 */
export const shouldBypassCache = window?.APP_SETTINGS?.user?.email?.endsWith(".e2e") ?? false;
 
/**
 * How long to keep queries in cache before garbage collecting them
 */
const DEFAULT_CACHE_TIME = 5 * 60 * 1000; // 5 minutes
const TEST_CACHE_TIME = 500; // 500 milliseconds to ensure proper deduping in application usage under test, but not long enough to cause issues in e2e tests
 
export const queryClient = new QC({
  defaultOptions: {
    queries: {
      refetchOnWindowFocus: false,
      cacheTime: shouldBypassCache ? TEST_CACHE_TIME : DEFAULT_CACHE_TIME,
    },
  },
});