@tanstack/solid-query 5.104.1 → 5.104.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dev.cjs +49 -21
- package/build/dev.js +49 -21
- package/build/index.d.cts +37 -88
- package/build/index.d.cts.map +1 -1
- package/build/index.d.ts +37 -88
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/package.json +5 -4
- package/src/QueryClient.ts +13 -5
- package/src/QueryClientProvider.tsx +9 -4
- package/src/infiniteQueryOptions.ts +2 -8
- package/src/isRestoring.ts +0 -1
- package/src/mutationOptions.ts +2 -6
- package/src/queryOptions.ts +2 -8
- package/src/types.ts +11 -18
- package/src/useBaseQuery.ts +36 -2
- package/src/useInfiniteQuery.ts +8 -13
- package/src/useIsFetching.ts +0 -2
- package/src/useIsMutating.ts +0 -2
- package/src/useMutation.ts +0 -6
- package/src/useMutationState.ts +7 -4
- package/src/useQueries.ts +0 -2
- package/src/useQuery.ts +2 -11
package/src/useQuery.ts
CHANGED
|
@@ -17,8 +17,6 @@ import type {
|
|
|
17
17
|
/**
|
|
18
18
|
* Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
19
19
|
* The query runs when the options call for it — `enabled: false` skips the initial fetch.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
22
20
|
* @param options - An accessor returning the {@link UndefinedInitialDataOptions} to use — everything you can
|
|
23
21
|
* pass to `useQuery`.
|
|
24
22
|
* @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
|
|
@@ -26,7 +24,7 @@ import type {
|
|
|
26
24
|
* @returns The current query result, as a Solid store. `status` is `pending` if there is no cached data to
|
|
27
25
|
* display, `error` if the last fetch attempt failed, or `success` if the query has data to display.
|
|
28
26
|
* `isPending`/`isSuccess`/`isError` are derived booleans for convenience.
|
|
29
|
-
*
|
|
27
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
30
28
|
* @example
|
|
31
29
|
* ```tsx
|
|
32
30
|
* import { For, Match, Switch } from 'solid-js'
|
|
@@ -52,7 +50,6 @@ import type {
|
|
|
52
50
|
* )
|
|
53
51
|
* }
|
|
54
52
|
* ```
|
|
55
|
-
*
|
|
56
53
|
* @example
|
|
57
54
|
* `select` derives whatever `data` a component needs from the cached value, without changing what's
|
|
58
55
|
* actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:
|
|
@@ -76,7 +73,6 @@ import type {
|
|
|
76
73
|
* )
|
|
77
74
|
* }
|
|
78
75
|
* ```
|
|
79
|
-
*
|
|
80
76
|
* @example
|
|
81
77
|
* A dependent query, only enabled once `postId` is set:
|
|
82
78
|
* ```tsx
|
|
@@ -99,7 +95,6 @@ import type {
|
|
|
99
95
|
* )
|
|
100
96
|
* }
|
|
101
97
|
* ```
|
|
102
|
-
*
|
|
103
98
|
* @example
|
|
104
99
|
* The same dependent query, using `skipToken` to disable it in a type-safe way instead of relying on
|
|
105
100
|
* `enabled`. The non-null assertion is still needed — Solid's `props` narrowing doesn't survive into the
|
|
@@ -125,7 +120,6 @@ import type {
|
|
|
125
120
|
* )
|
|
126
121
|
* }
|
|
127
122
|
* ```
|
|
128
|
-
*
|
|
129
123
|
* @example
|
|
130
124
|
* Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries
|
|
131
125
|
* over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was
|
|
@@ -150,7 +144,6 @@ import type {
|
|
|
150
144
|
* return postQuery.isError ? <span>Error: {postQuery.error.message}</span> : <h1>{postQuery.data?.title}</h1>
|
|
151
145
|
* }
|
|
152
146
|
* ```
|
|
153
|
-
*
|
|
154
147
|
* @example
|
|
155
148
|
* Paginated data, keeping the previous page's data visible while the next page loads:
|
|
156
149
|
* ```tsx
|
|
@@ -198,8 +191,6 @@ export function useQuery<
|
|
|
198
191
|
*
|
|
199
192
|
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
|
|
200
193
|
* a `select` changes `TData` to include `undefined`).
|
|
201
|
-
*
|
|
202
|
-
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
203
194
|
* @param options - An accessor returning the {@link DefinedInitialDataOptions} to use — everything you can
|
|
204
195
|
* pass to `useQuery`, with `initialData` set.
|
|
205
196
|
* @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
|
|
@@ -208,7 +199,7 @@ export function useQuery<
|
|
|
208
199
|
* fetch attempt fails while keeping the existing data (`status` never resolves to `pending` in this overload's
|
|
209
200
|
* type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for
|
|
210
201
|
* convenience.
|
|
211
|
-
*
|
|
202
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
212
203
|
* @example
|
|
213
204
|
* ```tsx
|
|
214
205
|
* import { For } from 'solid-js'
|