Open History to see the last commit
1import { QueryClient as QueryCoreClient } from '@tanstack/query-core'
2import type {
3 DefaultOptions as CoreDefaultOptions,
4 DefaultError,
5 OmitKeyof,
6 QueryClientConfig as QueryCoreClientConfig,
7 InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions,
8 QueryObserverOptions as QueryCoreObserverOptions,
9 QueryKey,
10} from '@tanstack/query-core'
11β
12/**
13 * Core observer options pass through unchanged. The old adapter omitted
14 * `structuralSharing` and replaced it with a store-level `reconcile`
15 * option; with reads derived directly from cache state, core's
16 * cache-level structural sharing is exactly what keeps the data memo
17 * referentially stable, so it is exposed again and `reconcile` is gone.
18 */
19export type QueryObserverOptions<
20 TQueryFnData = unknown,
21 TError = DefaultError,
22 TData = TQueryFnData,
23 TQueryData = TQueryFnData,
24 TQueryKey extends QueryKey = QueryKey,
25 TPageParam = never,
26> = QueryCoreObserverOptions<
27 TQueryFnData,
28 TError,
29 TData,
30 TQueryData,
31 TQueryKey,
32 TPageParam
33>
34β
35/**
36 * The core `InfiniteQueryObserverOptions`, passed through unchanged.
37 * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
38 * @template TError - The type of errors your `queryFn` may throw.
39 * @template TData - The type `data` ends up as after `select` runs.
40 * @template TQueryKey - The type of your `queryKey`.
41 * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
42 */
43export type InfiniteQueryObserverOptions<
44 TQueryFnData = unknown,
45 TError = DefaultError,
46 TData = TQueryFnData,
47 TQueryKey extends QueryKey = QueryKey,
48 TPageParam = unknown,
49> = QueryCoreInfiniteQueryObserverOptions<
50 TQueryFnData,
51 TError,
52 TData,
53 TQueryKey,
54 TPageParam
55>
56β
57/**
58 * The default options a `QueryClient` applies to every query and mutation.
59 * @template TError - The default type of errors thrown by queries and mutations using this `QueryClient`.
60 */
61export interface DefaultOptions<
62 TError = DefaultError,
63> extends CoreDefaultOptions<TError> {
64 /**
65 * Default options applied to every query, unless overridden per-query.
66 */
67 queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'queryKey'>
68}
69β
70/**
71 * The config accepted by `new QueryClient(config)`, with Solid's {@link DefaultOptions}.
72 */
73export interface QueryClientConfig extends QueryCoreClientConfig {
74 /**
75 * The default options of the queries and mutations of this `QueryClient`.
76 */
77 defaultOptions?: DefaultOptions
78}
79β
80/**
81 * The core `@tanstack/query-core` `QueryClient`, typed with Solid's {@link QueryClientConfig}.
82 */
83export class QueryClient extends QueryCoreClient {
84 constructor(config: QueryClientConfig = {}) {
85 super(config)
86 }
87}