@tanstack/query-core 5.55.4 → 5.56.1
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-BOOcDeHq.d.cts → hydration-D6canbuP.d.cts} +7 -2
- package/build/legacy/{hydration-DTVzC0E7.d.ts → hydration-DgUcX5FN.d.ts} +7 -2
- 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.cjs +14 -17
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.js +14 -17
- package/build/legacy/infiniteQueryBehavior.js.map +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.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.cjs +4 -0
- 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 +4 -0
- 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/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/modern/{hydration-BOOcDeHq.d.cts → hydration-D6canbuP.d.cts} +7 -2
- package/build/modern/{hydration-DTVzC0E7.d.ts → hydration-DgUcX5FN.d.ts} +7 -2
- 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.cjs +10 -13
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.js +10 -13
- package/build/modern/infiniteQueryBehavior.js.map +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.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.cjs +4 -0
- 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 +4 -0
- 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/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/infiniteQueryBehavior.test.tsx +74 -1
- package/src/__tests__/queryClient.test.tsx +63 -0
- package/src/infiniteQueryBehavior.ts +15 -18
- package/src/queryClient.ts +28 -2
- package/src/types.ts +26 -6
package/src/queryClient.ts
CHANGED
|
@@ -13,13 +13,13 @@ import { focusManager } from './focusManager'
|
|
|
13
13
|
import { onlineManager } from './onlineManager'
|
|
14
14
|
import { notifyManager } from './notifyManager'
|
|
15
15
|
import { infiniteQueryBehavior } from './infiniteQueryBehavior'
|
|
16
|
-
import type { QueryState } from './query'
|
|
17
16
|
import type {
|
|
18
17
|
CancelOptions,
|
|
19
18
|
DataTag,
|
|
20
19
|
DefaultError,
|
|
21
20
|
DefaultOptions,
|
|
22
21
|
DefaultedQueryObserverOptions,
|
|
22
|
+
EnsureInfiniteQueryDataOptions,
|
|
23
23
|
EnsureQueryDataOptions,
|
|
24
24
|
FetchInfiniteQueryOptions,
|
|
25
25
|
FetchQueryOptions,
|
|
@@ -40,6 +40,7 @@ import type {
|
|
|
40
40
|
ResetOptions,
|
|
41
41
|
SetDataOptions,
|
|
42
42
|
} from './types'
|
|
43
|
+
import type { QueryState } from './query'
|
|
43
44
|
import type { MutationFilters, QueryFilters, Updater } from './utils'
|
|
44
45
|
|
|
45
46
|
// TYPES
|
|
@@ -385,7 +386,7 @@ export class QueryClient {
|
|
|
385
386
|
TData,
|
|
386
387
|
TPageParam
|
|
387
388
|
>(options.pages)
|
|
388
|
-
return this.fetchQuery(options)
|
|
389
|
+
return this.fetchQuery(options as any)
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
prefetchInfiniteQuery<
|
|
@@ -406,6 +407,31 @@ export class QueryClient {
|
|
|
406
407
|
return this.fetchInfiniteQuery(options).then(noop).catch(noop)
|
|
407
408
|
}
|
|
408
409
|
|
|
410
|
+
ensureInfiniteQueryData<
|
|
411
|
+
TQueryFnData,
|
|
412
|
+
TError = DefaultError,
|
|
413
|
+
TData = TQueryFnData,
|
|
414
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
415
|
+
TPageParam = unknown,
|
|
416
|
+
>(
|
|
417
|
+
options: EnsureInfiniteQueryDataOptions<
|
|
418
|
+
TQueryFnData,
|
|
419
|
+
TError,
|
|
420
|
+
TData,
|
|
421
|
+
TQueryKey,
|
|
422
|
+
TPageParam
|
|
423
|
+
>,
|
|
424
|
+
): Promise<InfiniteData<TData, TPageParam>> {
|
|
425
|
+
options.behavior = infiniteQueryBehavior<
|
|
426
|
+
TQueryFnData,
|
|
427
|
+
TError,
|
|
428
|
+
TData,
|
|
429
|
+
TPageParam
|
|
430
|
+
>(options.pages)
|
|
431
|
+
|
|
432
|
+
return this.ensureQueryData(options as any)
|
|
433
|
+
}
|
|
434
|
+
|
|
409
435
|
resumePausedMutations(): Promise<unknown> {
|
|
410
436
|
if (onlineManager.isOnline()) {
|
|
411
437
|
return this.#mutationCache.resumePausedMutations()
|
package/src/types.ts
CHANGED
|
@@ -448,6 +448,7 @@ export interface FetchQueryOptions<
|
|
|
448
448
|
QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
|
|
449
449
|
'queryKey'
|
|
450
450
|
> {
|
|
451
|
+
initialPageParam?: never
|
|
451
452
|
/**
|
|
452
453
|
* The time in milliseconds after data is considered stale.
|
|
453
454
|
* If the data is fresh it will be returned from the cache.
|
|
@@ -471,6 +472,22 @@ export interface EnsureQueryDataOptions<
|
|
|
471
472
|
revalidateIfStale?: boolean
|
|
472
473
|
}
|
|
473
474
|
|
|
475
|
+
export type EnsureInfiniteQueryDataOptions<
|
|
476
|
+
TQueryFnData = unknown,
|
|
477
|
+
TError = DefaultError,
|
|
478
|
+
TData = TQueryFnData,
|
|
479
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
480
|
+
TPageParam = unknown,
|
|
481
|
+
> = FetchInfiniteQueryOptions<
|
|
482
|
+
TQueryFnData,
|
|
483
|
+
TError,
|
|
484
|
+
TData,
|
|
485
|
+
TQueryKey,
|
|
486
|
+
TPageParam
|
|
487
|
+
> & {
|
|
488
|
+
revalidateIfStale?: boolean
|
|
489
|
+
}
|
|
490
|
+
|
|
474
491
|
type FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =
|
|
475
492
|
| { pages?: never }
|
|
476
493
|
| {
|
|
@@ -484,12 +501,15 @@ export type FetchInfiniteQueryOptions<
|
|
|
484
501
|
TData = TQueryFnData,
|
|
485
502
|
TQueryKey extends QueryKey = QueryKey,
|
|
486
503
|
TPageParam = unknown,
|
|
487
|
-
> =
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
504
|
+
> = Omit<
|
|
505
|
+
FetchQueryOptions<
|
|
506
|
+
TQueryFnData,
|
|
507
|
+
TError,
|
|
508
|
+
InfiniteData<TData, TPageParam>,
|
|
509
|
+
TQueryKey,
|
|
510
|
+
TPageParam
|
|
511
|
+
>,
|
|
512
|
+
'initialPageParam'
|
|
493
513
|
> &
|
|
494
514
|
InitialPageParam<TPageParam> &
|
|
495
515
|
FetchInfiniteQueryPages<TQueryFnData, TPageParam>
|