Open History to see the last commit
1import type { NativeApi } from "@t3tools/contracts";
2import { queryOptions } from "@tanstack/react-query";
3
4export const serverQueryKeys = {
5 all: ["server"] as const,
6 config: () => ["server", "config"] as const,
7};
8
9export function serverConfigQueryOptions(api: NativeApi | undefined) {
10 return queryOptions({
11 queryKey: serverQueryKeys.config(),
12 queryFn: async () => {
13 if (!api || !api.server || typeof api.server.getConfig !== "function") {
14 throw new Error("Server config is unavailable.");
15 }
16 return api.server.getConfig();
17 },
18 enabled: !!api && !!api.server && typeof api.server.getConfig === "function",
19 staleTime: Infinity,
20 });
21}