@tanstack/query-core 5.0.0-beta.14 → 5.0.0-beta.18
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.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 +1 -1
- 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 +1 -1
- 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-6d6b4ed8.d.ts → queryClient-45da873e.d.ts} +5 -5
- package/build/legacy/{queryClient-58ec0ff3.d.ts → queryClient-66e0f244.d.ts} +5 -5
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.cjs +1 -1
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/queryObserver.js +1 -1
- package/build/legacy/queryObserver.js.map +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.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 +1 -1
- 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 +1 -1
- 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-6d6b4ed8.d.ts → queryClient-45da873e.d.ts} +5 -5
- package/build/modern/{queryClient-58ec0ff3.d.ts → queryClient-66e0f244.d.ts} +5 -5
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.cjs +1 -1
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/queryObserver.js +1 -1
- package/build/modern/queryObserver.js.map +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/infiniteQueryBehavior.ts +1 -1
- package/src/queryObserver.ts +1 -1
- package/src/tests/infiniteQueryBehavior.test.tsx +4 -4
- package/src/tests/infiniteQueryObserver.test.tsx +5 -5
- package/src/tests/queryClient.test.tsx +6 -6
- package/src/types.ts +4 -4
package/build/modern/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aw as CancelOptions, D as DefaultError, av as DefaultOptions,
|
|
1
|
+
export { aw as CancelOptions, D as DefaultError, av as DefaultOptions, J as DefaultedInfiniteQueryObserverOptions, F as DefaultedQueryObserverOptions, ae as DefinedInfiniteQueryObserverResult, a7 as DefinedQueryObserverResult, L as FetchInfiniteQueryOptions, _ as FetchNextPageOptions, $ as FetchPreviousPageOptions, K as FetchQueryOptions, a1 as FetchStatus, v as GetNextPageParamFunction, G as GetPreviousPageParamFunction, w as InfiniteData, a9 as InfiniteQueryObserverBaseResult, ab as InfiniteQueryObserverLoadingErrorResult, aa as InfiniteQueryObserverLoadingResult, H as InfiniteQueryObserverOptions, ac as InfiniteQueryObserverRefetchErrorResult, af as InfiniteQueryObserverResult, ad as InfiniteQueryObserverSuccessResult, B as InfiniteQueryPageParamsOptions, I as InitialDataFunction, A as InitialPageParam, Y as InvalidateOptions, V as InvalidateQueryFilters, an as MutateFunction, am as MutateOptions, aj as MutationFunction, ag as MutationKey, ai as MutationMeta, ao as MutationObserverBaseResult, ar as MutationObserverErrorResult, ap as MutationObserverIdleResult, aq as MutationObserverLoadingResult, al as MutationObserverOptions, at as MutationObserverResult, as as MutationObserverSuccessResult, ak as MutationOptions, ah as MutationStatus, N as NetworkMode, az as NotifyEvent, ay as NotifyEventType, y as NotifyOnChangeProps, P as PlaceholderDataFunction, t as QueriesPlaceholderDataFunction, au as QueryClientConfig, q as QueryFunction, s as QueryFunctionContext, p as QueryKey, u as QueryKeyHashFunction, x as QueryMeta, a2 as QueryObserverBaseResult, a4 as QueryObserverLoadingErrorResult, a3 as QueryObserverLoadingResult, E as QueryObserverOptions, a5 as QueryObserverRefetchErrorResult, a8 as QueryObserverResult, a6 as QueryObserverSuccessResult, z as QueryOptions, a0 as QueryStatus, S as RefetchOptions, X as RefetchQueryFilters, R as Register, Z as ResetOptions, O as ResultOptions, ax as SetDataOptions, T as ThrowOnError, W as WithRequired } from './queryClient-66e0f244.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/build/modern/utils.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aD as DataUpdateFunction, e as MutationFilters, f as QueryFilters, aE as QueryTypeFilter, U as Updater, aS as addToEnd, aT as addToStart, aG as functionalUpdate, h as hashKey, aK as hashQueryKeyByOptions, aN as isPlainArray, aO as isPlainObject, i as isServer, aH as isValidTimeout, k as keepPreviousData, aJ as matchMutation, m as matchQuery, aF as noop, aL as partialMatchKey, aR as replaceData, r as replaceEqualDeep, aQ as scheduleMicrotask, aM as shallowEqualObjects, aP as sleep, aI as timeUntilStale } from './queryClient-
|
|
1
|
+
export { aD as DataUpdateFunction, e as MutationFilters, f as QueryFilters, aE as QueryTypeFilter, U as Updater, aS as addToEnd, aT as addToStart, aG as functionalUpdate, h as hashKey, aK as hashQueryKeyByOptions, aN as isPlainArray, aO as isPlainObject, i as isServer, aH as isValidTimeout, k as keepPreviousData, aJ as matchMutation, m as matchQuery, aF as noop, aL as partialMatchKey, aR as replaceData, r as replaceEqualDeep, aQ as scheduleMicrotask, aM as shallowEqualObjects, aP as sleep, aI as timeUntilStale } from './queryClient-45da873e.js';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
package/build/modern/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aD as DataUpdateFunction, e as MutationFilters, f as QueryFilters, aE as QueryTypeFilter, U as Updater, aS as addToEnd, aT as addToStart, aG as functionalUpdate, h as hashKey, aK as hashQueryKeyByOptions, aN as isPlainArray, aO as isPlainObject, i as isServer, aH as isValidTimeout, k as keepPreviousData, aJ as matchMutation, m as matchQuery, aF as noop, aL as partialMatchKey, aR as replaceData, r as replaceEqualDeep, aQ as scheduleMicrotask, aM as shallowEqualObjects, aP as sleep, aI as timeUntilStale } from './queryClient-
|
|
1
|
+
export { aD as DataUpdateFunction, e as MutationFilters, f as QueryFilters, aE as QueryTypeFilter, U as Updater, aS as addToEnd, aT as addToStart, aG as functionalUpdate, h as hashKey, aK as hashQueryKeyByOptions, aN as isPlainArray, aO as isPlainObject, i as isServer, aH as isValidTimeout, k as keepPreviousData, aJ as matchMutation, m as matchQuery, aF as noop, aL as partialMatchKey, aR as replaceData, r as replaceEqualDeep, aQ as scheduleMicrotask, aM as shallowEqualObjects, aP as sleep, aI as timeUntilStale } from './queryClient-66e0f244.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/package.json
CHANGED
|
@@ -100,7 +100,7 @@ export function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(
|
|
|
100
100
|
// Fetch first page
|
|
101
101
|
result = await fetchPage(
|
|
102
102
|
empty,
|
|
103
|
-
oldPageParams[0] ?? options.
|
|
103
|
+
oldPageParams[0] ?? options.initialPageParam,
|
|
104
104
|
)
|
|
105
105
|
|
|
106
106
|
const remainingPages = pages ?? oldPages.length
|
package/src/queryObserver.ts
CHANGED
|
@@ -763,7 +763,7 @@ function shouldAssignObserverCurrentProperties<
|
|
|
763
763
|
) {
|
|
764
764
|
// if the newly created result isn't what the observer is holding as current,
|
|
765
765
|
// then we'll need to update the properties as well
|
|
766
|
-
if (observer.getCurrentResult()
|
|
766
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
767
767
|
return true
|
|
768
768
|
}
|
|
769
769
|
|
|
@@ -24,7 +24,7 @@ describe('InfiniteQueryBehavior', () => {
|
|
|
24
24
|
const observer = new InfiniteQueryObserver(queryClient, {
|
|
25
25
|
queryKey: key,
|
|
26
26
|
retry: false,
|
|
27
|
-
|
|
27
|
+
initialPageParam: 1,
|
|
28
28
|
getNextPageParam: () => 2,
|
|
29
29
|
})
|
|
30
30
|
|
|
@@ -62,7 +62,7 @@ describe('InfiniteQueryBehavior', () => {
|
|
|
62
62
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
63
63
|
getPreviousPageParam: (firstPage) => firstPage - 1,
|
|
64
64
|
maxPages: 2,
|
|
65
|
-
|
|
65
|
+
initialPageParam: 1,
|
|
66
66
|
})
|
|
67
67
|
|
|
68
68
|
let observerResult:
|
|
@@ -204,7 +204,7 @@ describe('InfiniteQueryBehavior', () => {
|
|
|
204
204
|
queryFn: queryFnSpy,
|
|
205
205
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
206
206
|
getPreviousPageParam: (firstPage) => firstPage - 1,
|
|
207
|
-
|
|
207
|
+
initialPageParam: 1,
|
|
208
208
|
})
|
|
209
209
|
|
|
210
210
|
let observerResult:
|
|
@@ -255,7 +255,7 @@ describe('InfiniteQueryBehavior', () => {
|
|
|
255
255
|
queryFn: queryFnSpy,
|
|
256
256
|
getNextPageParam: (lastPage) => lastPage + 1,
|
|
257
257
|
getPreviousPageParam: (firstPage) => firstPage - 1,
|
|
258
|
-
|
|
258
|
+
initialPageParam: 1,
|
|
259
259
|
})
|
|
260
260
|
|
|
261
261
|
let observerResult:
|
|
@@ -24,7 +24,7 @@ describe('InfiniteQueryObserver', () => {
|
|
|
24
24
|
pages: data.pages.map((x) => `${x}`),
|
|
25
25
|
pageParams: data.pageParams,
|
|
26
26
|
}),
|
|
27
|
-
|
|
27
|
+
initialPageParam: 1,
|
|
28
28
|
getNextPageParam: () => 2,
|
|
29
29
|
})
|
|
30
30
|
let observerResult
|
|
@@ -53,7 +53,7 @@ describe('InfiniteQueryObserver', () => {
|
|
|
53
53
|
pages: data.pages.map((x) => `${x}`),
|
|
54
54
|
pageParams: data.pageParams,
|
|
55
55
|
}),
|
|
56
|
-
|
|
56
|
+
initialPageParam: 1,
|
|
57
57
|
getNextPageParam: () => 2,
|
|
58
58
|
})
|
|
59
59
|
let observerResult
|
|
@@ -75,7 +75,7 @@ describe('InfiniteQueryObserver', () => {
|
|
|
75
75
|
const observer = new InfiniteQueryObserver(queryClient, {
|
|
76
76
|
queryKey: key,
|
|
77
77
|
queryFn: ({ pageParam }) => String(pageParam),
|
|
78
|
-
|
|
78
|
+
initialPageParam: 1,
|
|
79
79
|
getNextPageParam: (_, __, lastPageParam, allPageParams) => {
|
|
80
80
|
single.push('next' + lastPageParam)
|
|
81
81
|
all.push('next' + allPageParams.join(','))
|
|
@@ -110,7 +110,7 @@ describe('InfiniteQueryObserver', () => {
|
|
|
110
110
|
const observer = new InfiniteQueryObserver(queryClient, {
|
|
111
111
|
queryKey: key,
|
|
112
112
|
queryFn,
|
|
113
|
-
|
|
113
|
+
initialPageParam: 1,
|
|
114
114
|
getNextPageParam: () => next,
|
|
115
115
|
})
|
|
116
116
|
|
|
@@ -137,7 +137,7 @@ describe('InfiniteQueryObserver', () => {
|
|
|
137
137
|
const observer = new InfiniteQueryObserver(queryClient, {
|
|
138
138
|
queryKey: key,
|
|
139
139
|
queryFn,
|
|
140
|
-
|
|
140
|
+
initialPageParam: 1,
|
|
141
141
|
getNextPageParam: () => next,
|
|
142
142
|
})
|
|
143
143
|
|
|
@@ -584,7 +584,7 @@ describe('queryClient', () => {
|
|
|
584
584
|
StrictData,
|
|
585
585
|
StrictQueryKey,
|
|
586
586
|
number
|
|
587
|
-
>({ queryKey: key, queryFn: fetchFn,
|
|
587
|
+
>({ queryKey: key, queryFn: fetchFn, initialPageParam: 0 }),
|
|
588
588
|
).resolves.toEqual(data)
|
|
589
589
|
})
|
|
590
590
|
|
|
@@ -592,7 +592,7 @@ describe('queryClient', () => {
|
|
|
592
592
|
const key = queryKey()
|
|
593
593
|
const result = await queryClient.fetchInfiniteQuery({
|
|
594
594
|
queryKey: key,
|
|
595
|
-
|
|
595
|
+
initialPageParam: 10,
|
|
596
596
|
queryFn: ({ pageParam }) => Number(pageParam),
|
|
597
597
|
})
|
|
598
598
|
const result2 = queryClient.getQueryData(key)
|
|
@@ -622,7 +622,7 @@ describe('queryClient', () => {
|
|
|
622
622
|
StrictData,
|
|
623
623
|
StrictQueryKey,
|
|
624
624
|
number
|
|
625
|
-
>({ queryKey: key, queryFn: fetchFn,
|
|
625
|
+
>({ queryKey: key, queryFn: fetchFn, initialPageParam: 0 })
|
|
626
626
|
|
|
627
627
|
const result = queryClient.getQueryData(key)
|
|
628
628
|
|
|
@@ -638,7 +638,7 @@ describe('queryClient', () => {
|
|
|
638
638
|
await queryClient.prefetchInfiniteQuery({
|
|
639
639
|
queryKey: key,
|
|
640
640
|
queryFn: ({ pageParam }) => Number(pageParam),
|
|
641
|
-
|
|
641
|
+
initialPageParam: 10,
|
|
642
642
|
})
|
|
643
643
|
|
|
644
644
|
const result = queryClient.getQueryData(key)
|
|
@@ -657,7 +657,7 @@ describe('queryClient', () => {
|
|
|
657
657
|
queryFn: ({ pageParam }) => String(pageParam),
|
|
658
658
|
getNextPageParam: (_lastPage, _pages, lastPageParam) =>
|
|
659
659
|
lastPageParam + 5,
|
|
660
|
-
|
|
660
|
+
initialPageParam: 10,
|
|
661
661
|
pages: 3,
|
|
662
662
|
})
|
|
663
663
|
|
|
@@ -677,7 +677,7 @@ describe('queryClient', () => {
|
|
|
677
677
|
queryFn: ({ pageParam }) => String(pageParam),
|
|
678
678
|
getNextPageParam: (_lastPage, _pages, lastPageParam) =>
|
|
679
679
|
lastPageParam >= 20 ? undefined : lastPageParam + 5,
|
|
680
|
-
|
|
680
|
+
initialPageParam: 10,
|
|
681
681
|
pages: 5,
|
|
682
682
|
})
|
|
683
683
|
|
package/src/types.ts
CHANGED
|
@@ -144,14 +144,14 @@ export interface QueryOptions<
|
|
|
144
144
|
maxPages?: number
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
export interface
|
|
148
|
-
|
|
147
|
+
export interface InitialPageParam<TPageParam = unknown> {
|
|
148
|
+
initialPageParam: TPageParam
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
export interface InfiniteQueryPageParamsOptions<
|
|
152
152
|
TQueryFnData = unknown,
|
|
153
153
|
TPageParam = unknown,
|
|
154
|
-
> extends
|
|
154
|
+
> extends InitialPageParam<TPageParam> {
|
|
155
155
|
/**
|
|
156
156
|
* This function can be set to automatically get the previous cursor for infinite queries.
|
|
157
157
|
* The result will also be used to determine the value of `hasPreviousPage`.
|
|
@@ -384,7 +384,7 @@ export type FetchInfiniteQueryOptions<
|
|
|
384
384
|
TQueryKey,
|
|
385
385
|
TPageParam
|
|
386
386
|
> &
|
|
387
|
-
|
|
387
|
+
InitialPageParam<TPageParam> &
|
|
388
388
|
FetchInfiniteQueryPages<TQueryFnData, TPageParam>
|
|
389
389
|
|
|
390
390
|
export interface ResultOptions {
|