@tanstack/query-core 5.66.11 → 5.67.0
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/legacy/{hydration-k2LfsAVL.d.ts → hydration-BgxG8UJ6.d.ts} +12 -10
- package/build/legacy/{hydration-BHYO6Wdv.d.cts → hydration-Cen8k-09.d.cts} +12 -10
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient.cjs +14 -10
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js +14 -10
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/modern/{hydration-k2LfsAVL.d.ts → hydration-BgxG8UJ6.d.ts} +12 -10
- package/build/modern/{hydration-BHYO6Wdv.d.cts → hydration-Cen8k-09.d.cts} +12 -10
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient.cjs +14 -10
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js +14 -10
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/queryCache.ts +1 -1
- package/src/queryClient.ts +83 -63
- package/src/types.ts +12 -0
package/src/queryClient.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { notifyManager } from './notifyManager'
|
|
|
15
15
|
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
|
|
16
16
|
import type {
|
|
17
17
|
CancelOptions,
|
|
18
|
-
DataTag,
|
|
19
18
|
DefaultError,
|
|
20
19
|
DefaultOptions,
|
|
21
20
|
DefaultedQueryObserverOptions,
|
|
@@ -23,6 +22,8 @@ import type {
|
|
|
23
22
|
EnsureQueryDataOptions,
|
|
24
23
|
FetchInfiniteQueryOptions,
|
|
25
24
|
FetchQueryOptions,
|
|
25
|
+
InferDataFromTag,
|
|
26
|
+
InferErrorFromTag,
|
|
26
27
|
InfiniteData,
|
|
27
28
|
InvalidateOptions,
|
|
28
29
|
InvalidateQueryFilters,
|
|
@@ -39,7 +40,6 @@ import type {
|
|
|
39
40
|
RefetchQueryFilters,
|
|
40
41
|
ResetOptions,
|
|
41
42
|
SetDataOptions,
|
|
42
|
-
UnsetMarker,
|
|
43
43
|
} from './types'
|
|
44
44
|
import type { QueryState } from './query'
|
|
45
45
|
import type { MutationFilters, QueryFilters, Updater } from './utils'
|
|
@@ -122,13 +122,7 @@ export class QueryClient {
|
|
|
122
122
|
getQueryData<
|
|
123
123
|
TQueryFnData = unknown,
|
|
124
124
|
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
125
|
-
TInferredQueryFnData = TTaggedQueryKey
|
|
126
|
-
unknown,
|
|
127
|
-
infer TaggedValue,
|
|
128
|
-
unknown
|
|
129
|
-
>
|
|
130
|
-
? TaggedValue
|
|
131
|
-
: TQueryFnData,
|
|
125
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
132
126
|
>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined {
|
|
133
127
|
const options = this.defaultQueryOptions({ queryKey })
|
|
134
128
|
|
|
@@ -191,13 +185,7 @@ export class QueryClient {
|
|
|
191
185
|
setQueryData<
|
|
192
186
|
TQueryFnData = unknown,
|
|
193
187
|
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
194
|
-
TInferredQueryFnData = TTaggedQueryKey
|
|
195
|
-
unknown,
|
|
196
|
-
infer TaggedValue,
|
|
197
|
-
unknown
|
|
198
|
-
>
|
|
199
|
-
? TaggedValue
|
|
200
|
-
: TQueryFnData,
|
|
188
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
201
189
|
>(
|
|
202
190
|
queryKey: TTaggedQueryKey,
|
|
203
191
|
updater: Updater<
|
|
@@ -267,22 +255,8 @@ export class QueryClient {
|
|
|
267
255
|
TQueryFnData = unknown,
|
|
268
256
|
TError = DefaultError,
|
|
269
257
|
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
270
|
-
TInferredQueryFnData = TTaggedQueryKey
|
|
271
|
-
|
|
272
|
-
infer TaggedValue,
|
|
273
|
-
unknown
|
|
274
|
-
>
|
|
275
|
-
? TaggedValue
|
|
276
|
-
: TQueryFnData,
|
|
277
|
-
TInferredError = TTaggedQueryKey extends DataTag<
|
|
278
|
-
unknown,
|
|
279
|
-
unknown,
|
|
280
|
-
infer TaggedError
|
|
281
|
-
>
|
|
282
|
-
? TaggedError extends UnsetMarker
|
|
283
|
-
? TError
|
|
284
|
-
: TaggedError
|
|
285
|
-
: TError,
|
|
258
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
259
|
+
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
286
260
|
>(
|
|
287
261
|
queryKey: TTaggedQueryKey,
|
|
288
262
|
): QueryState<TInferredQueryFnData, TInferredError> | undefined {
|
|
@@ -293,8 +267,19 @@ export class QueryClient {
|
|
|
293
267
|
}
|
|
294
268
|
|
|
295
269
|
removeQueries<
|
|
296
|
-
|
|
297
|
-
|
|
270
|
+
TQueryFnData = unknown,
|
|
271
|
+
TError = DefaultError,
|
|
272
|
+
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
273
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
274
|
+
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
275
|
+
>(
|
|
276
|
+
filters?: QueryFilters<
|
|
277
|
+
TInferredQueryFnData,
|
|
278
|
+
TInferredError,
|
|
279
|
+
TInferredQueryFnData,
|
|
280
|
+
TTaggedQueryKey
|
|
281
|
+
>,
|
|
282
|
+
): void {
|
|
298
283
|
const queryCache = this.#queryCache
|
|
299
284
|
notifyManager.batch(() => {
|
|
300
285
|
queryCache.findAll(filters).forEach((query) => {
|
|
@@ -304,26 +289,51 @@ export class QueryClient {
|
|
|
304
289
|
}
|
|
305
290
|
|
|
306
291
|
resetQueries<
|
|
307
|
-
|
|
308
|
-
|
|
292
|
+
TQueryFnData = unknown,
|
|
293
|
+
TError = DefaultError,
|
|
294
|
+
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
295
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
296
|
+
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
297
|
+
>(
|
|
298
|
+
filters?: QueryFilters<
|
|
299
|
+
TInferredQueryFnData,
|
|
300
|
+
TInferredError,
|
|
301
|
+
TInferredQueryFnData,
|
|
302
|
+
TTaggedQueryKey
|
|
303
|
+
>,
|
|
304
|
+
options?: ResetOptions,
|
|
305
|
+
): Promise<void> {
|
|
309
306
|
const queryCache = this.#queryCache
|
|
310
307
|
|
|
311
|
-
const refetchFilters: RefetchQueryFilters = {
|
|
312
|
-
type: 'active',
|
|
313
|
-
...filters,
|
|
314
|
-
}
|
|
315
|
-
|
|
316
308
|
return notifyManager.batch(() => {
|
|
317
309
|
queryCache.findAll(filters).forEach((query) => {
|
|
318
310
|
query.reset()
|
|
319
311
|
})
|
|
320
|
-
return this.refetchQueries(
|
|
312
|
+
return this.refetchQueries(
|
|
313
|
+
{
|
|
314
|
+
type: 'active',
|
|
315
|
+
...filters,
|
|
316
|
+
},
|
|
317
|
+
options,
|
|
318
|
+
)
|
|
321
319
|
})
|
|
322
320
|
}
|
|
323
321
|
|
|
324
322
|
cancelQueries<
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
TQueryFnData = unknown,
|
|
324
|
+
TError = DefaultError,
|
|
325
|
+
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
326
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
327
|
+
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
328
|
+
>(
|
|
329
|
+
filters?: QueryFilters<
|
|
330
|
+
TInferredQueryFnData,
|
|
331
|
+
TInferredError,
|
|
332
|
+
TInferredQueryFnData,
|
|
333
|
+
TTaggedQueryKey
|
|
334
|
+
>,
|
|
335
|
+
cancelOptions: CancelOptions = {},
|
|
336
|
+
): Promise<void> {
|
|
327
337
|
const defaultedCancelOptions = { revert: true, ...cancelOptions }
|
|
328
338
|
|
|
329
339
|
const promises = notifyManager.batch(() =>
|
|
@@ -336,14 +346,18 @@ export class QueryClient {
|
|
|
336
346
|
}
|
|
337
347
|
|
|
338
348
|
invalidateQueries<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
> = InvalidateQueryFilters,
|
|
349
|
+
TQueryFnData = unknown,
|
|
350
|
+
TError = DefaultError,
|
|
351
|
+
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
352
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
353
|
+
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
345
354
|
>(
|
|
346
|
-
filters?:
|
|
355
|
+
filters?: InvalidateQueryFilters<
|
|
356
|
+
TInferredQueryFnData,
|
|
357
|
+
TInferredError,
|
|
358
|
+
TInferredQueryFnData,
|
|
359
|
+
TTaggedQueryKey
|
|
360
|
+
>,
|
|
347
361
|
options: InvalidateOptions = {},
|
|
348
362
|
): Promise<void> {
|
|
349
363
|
return notifyManager.batch(() => {
|
|
@@ -354,23 +368,29 @@ export class QueryClient {
|
|
|
354
368
|
if (filters?.refetchType === 'none') {
|
|
355
369
|
return Promise.resolve()
|
|
356
370
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
371
|
+
return this.refetchQueries(
|
|
372
|
+
{
|
|
373
|
+
...filters,
|
|
374
|
+
type: filters?.refetchType ?? filters?.type ?? 'active',
|
|
375
|
+
},
|
|
376
|
+
options,
|
|
377
|
+
)
|
|
362
378
|
})
|
|
363
379
|
}
|
|
364
380
|
|
|
365
381
|
refetchQueries<
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
> = RefetchQueryFilters,
|
|
382
|
+
TQueryFnData = unknown,
|
|
383
|
+
TError = DefaultError,
|
|
384
|
+
TTaggedQueryKey extends QueryKey = QueryKey,
|
|
385
|
+
TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,
|
|
386
|
+
TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,
|
|
372
387
|
>(
|
|
373
|
-
filters?:
|
|
388
|
+
filters?: RefetchQueryFilters<
|
|
389
|
+
TInferredQueryFnData,
|
|
390
|
+
TInferredError,
|
|
391
|
+
TInferredQueryFnData,
|
|
392
|
+
TTaggedQueryKey
|
|
393
|
+
>,
|
|
374
394
|
options: RefetchOptions = {},
|
|
375
395
|
): Promise<void> {
|
|
376
396
|
const fetchOptions = {
|
package/src/types.ts
CHANGED
|
@@ -74,6 +74,18 @@ export type DataTag<
|
|
|
74
74
|
[dataTagErrorSymbol]: TError
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export type InferDataFromTag<TQueryFnData, TTaggedQueryKey extends QueryKey> =
|
|
78
|
+
TTaggedQueryKey extends DataTag<unknown, infer TaggedValue, unknown>
|
|
79
|
+
? TaggedValue
|
|
80
|
+
: TQueryFnData
|
|
81
|
+
|
|
82
|
+
export type InferErrorFromTag<TError, TTaggedQueryKey extends QueryKey> =
|
|
83
|
+
TTaggedQueryKey extends DataTag<unknown, unknown, infer TaggedError>
|
|
84
|
+
? TaggedError extends UnsetMarker
|
|
85
|
+
? TError
|
|
86
|
+
: TaggedError
|
|
87
|
+
: TError
|
|
88
|
+
|
|
77
89
|
export type QueryFunction<
|
|
78
90
|
T = unknown,
|
|
79
91
|
TQueryKey extends QueryKey = QueryKey,
|