"use client";

import { QueryClient } from "@tanstack/react-query";
import { ApiError, NotConnected } from "./api";

export const queryClient = new QueryClient({
    defaultOptions: {
        queries: {
            staleTime: 30_000,
            // Retrying a 401 or a missing API URL just delays the redirect and
            // the not-connected panel.
            retry: (count, error) =>
                error instanceof NotConnected || error instanceof ApiError ? false : count < 1,
        },
    },
});
