summaryrefslogtreecommitdiff
path: root/apps/web/lib/query-client.ts
blob: 421fc3a532802434a4c3a7145380eaabb6137a03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { QueryClient } from "@tanstack/react-query"

const TWENTY_FOUR_HOURS_IN_MILLISECONDS = 1000 * 60 * 60 * 24

export const MUTATION_KEYS = {
  toggleEntryReadState: ["toggle-entry-read-state"] as const,
  toggleEntrySavedState: ["toggle-entry-saved-state"] as const,
}

export function createQueryClient() {
  return new QueryClient({
    defaultOptions: {
      queries: {
        staleTime: 60_000,
        gcTime: TWENTY_FOUR_HOURS_IN_MILLISECONDS,
        refetchOnWindowFocus: false,
      },
      mutations: {
        networkMode: "online",
        gcTime: TWENTY_FOUR_HOURS_IN_MILLISECONDS,
      },
    },
  })
}