MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / buildQueryClient

Function buildQueryClient

console/src/queryClient.ts:15–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13import { getStore } from "./jotai";
14
15export function buildQueryClient() {
16 const { reactQueryRetriesEnabled } = getStore().get(appConfigAtom);
17
18 return new QueryClient({
19 defaultOptions: {
20 queries: {
21 retry: (failureCount, error) => {
22 // Retries are disabled in test
23 if (!reactQueryRetriesEnabled) return false;
24 if (error.cause && (error.cause as any).status === 401) {
25 // When a request is unauthorized, we want to fail fast and refresh the token.
26 // In practice, the token should be refreshed by the middleware, so we should
27 // only see this on the actual refresh token call which doesn't have the
28 // middleware.
29 return false;
30 }
31 // Some custom error have a `skipQueryRetry` field to skip retries,
32 // e.g. NoRowsError.
33 if (
34 error instanceof Error &&
35 "skipQueryRetry" in error &&
36 error.skipQueryRetry
37 ) {
38 return false;
39 }
40 return failureCount < 3;
41 },
42 },
43 },
44 });
45}
46
47let queryClient = buildQueryClient();
48

Callers 3

queryClient.tsFile · 0.85
resetQueryClientFunction · 0.85

Calls 2

getStoreFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected