@tanstack/query-core 4.0.10 → 4.0.11-beta.4
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/{types/packages/query-core/src → lib}/focusManager.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/hydration.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/index.d.ts +2 -2
- package/build/lib/index.js +3115 -0
- package/build/lib/index.js.map +1 -0
- package/build/{esm/index.js → lib/index.mjs} +22 -7
- package/build/lib/index.mjs.map +1 -0
- package/build/{types/packages/query-core/src → lib}/infiniteQueryBehavior.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/infiniteQueryObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/logger.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/logger.native.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/mutation.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/mutationCache.d.ts +6 -1
- package/build/{types/packages/query-core/src → lib}/mutationObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/notifyManager.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/onlineManager.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queriesObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/query.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queryCache.d.ts +6 -1
- package/build/{types/packages/query-core/src → lib}/queryClient.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/queryObserver.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/removable.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/retryer.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/subscribable.d.ts +0 -0
- package/build/{types/packages/query-core/src → lib}/types.d.ts +10 -8
- package/build/{types/packages/query-core/src → lib}/utils.d.ts +0 -0
- package/build/umd/index.development.js +21 -6
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +16 -8
- package/src/index.ts +2 -2
- package/src/mutationCache.ts +7 -0
- package/src/mutationObserver.ts +9 -0
- package/src/queryCache.ts +7 -0
- package/src/queryClient.ts +10 -14
- package/src/queryObserver.ts +8 -0
- package/src/tests/queryClient.test.tsx +33 -0
- package/src/tests/queryObserver.test.tsx +19 -0
- package/src/types.ts +15 -9
- package/src/utils.ts +2 -0
- package/build/cjs/focusManager.js +0 -101
- package/build/cjs/focusManager.js.map +0 -1
- package/build/cjs/hydration.js +0 -112
- package/build/cjs/hydration.js.map +0 -1
- package/build/cjs/index.js +0 -51
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/infiniteQueryBehavior.js +0 -160
- package/build/cjs/infiniteQueryBehavior.js.map +0 -1
- package/build/cjs/infiniteQueryObserver.js +0 -92
- package/build/cjs/infiniteQueryObserver.js.map +0 -1
- package/build/cjs/logger.js +0 -18
- package/build/cjs/logger.js.map +0 -1
- package/build/cjs/mutation.js +0 -258
- package/build/cjs/mutation.js.map +0 -1
- package/build/cjs/mutationCache.js +0 -99
- package/build/cjs/mutationCache.js.map +0 -1
- package/build/cjs/mutationObserver.js +0 -130
- package/build/cjs/mutationObserver.js.map +0 -1
- package/build/cjs/notifyManager.js +0 -114
- package/build/cjs/notifyManager.js.map +0 -1
- package/build/cjs/onlineManager.js +0 -100
- package/build/cjs/onlineManager.js.map +0 -1
- package/build/cjs/queriesObserver.js +0 -170
- package/build/cjs/queriesObserver.js.map +0 -1
- package/build/cjs/query.js +0 -474
- package/build/cjs/query.js.map +0 -1
- package/build/cjs/queryCache.js +0 -140
- package/build/cjs/queryCache.js.map +0 -1
- package/build/cjs/queryClient.js +0 -357
- package/build/cjs/queryClient.js.map +0 -1
- package/build/cjs/queryObserver.js +0 -521
- package/build/cjs/queryObserver.js.map +0 -1
- package/build/cjs/removable.js +0 -47
- package/build/cjs/removable.js.map +0 -1
- package/build/cjs/retryer.js +0 -177
- package/build/cjs/retryer.js.map +0 -1
- package/build/cjs/subscribable.js +0 -43
- package/build/cjs/subscribable.js.map +0 -1
- package/build/cjs/utils.js +0 -356
- package/build/cjs/utils.js.map +0 -1
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -2689
- package/build/stats.json +0 -805
- package/build/types/packages/query-core/src/tests/focusManager.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/hydration.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/infiniteQueryBehavior.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/infiniteQueryObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/mutationCache.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/mutationObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/mutations.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/notifyManager.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/onlineManager.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queriesObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/query.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queryCache.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queryClient.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/queryObserver.test.d.ts +0 -1
- package/build/types/packages/query-core/src/tests/utils.test.d.ts +0 -1
- package/build/types/tests/utils.d.ts +0 -24
|
@@ -341,6 +341,8 @@ function replaceData(prevData, data, options) {
|
|
|
341
341
|
// Use prev data if an isDataEqual function is defined and returns `true`
|
|
342
342
|
if (options.isDataEqual != null && options.isDataEqual(prevData, data)) {
|
|
343
343
|
return prevData;
|
|
344
|
+
} else if (typeof options.structuralSharing === 'function') {
|
|
345
|
+
return options.structuralSharing(prevData, data);
|
|
344
346
|
} else if (options.structuralSharing !== false) {
|
|
345
347
|
// Structurally share data between prev and new data if needed
|
|
346
348
|
return replaceEqualDeep(prevData, data);
|
|
@@ -2057,9 +2059,7 @@ class QueryClient {
|
|
|
2057
2059
|
const matchingDefaults = this.queryDefaults.filter(x => partialMatchKey(queryKey, x.queryKey)); // It is ok not having defaults, but it is error prone to have more than 1 default for a given key
|
|
2058
2060
|
|
|
2059
2061
|
if (matchingDefaults.length > 1) {
|
|
2060
|
-
|
|
2061
|
-
this.logger.error("[QueryClient] Several query defaults match with key '" + JSON.stringify(queryKey) + "'. The first matching query defaults are used. Please check how query defaults are registered. Order does matter here. cf. https://react-query.tanstack.com/reference/QueryClient#queryclientsetquerydefaults.");
|
|
2062
|
-
}
|
|
2062
|
+
this.logger.error("[QueryClient] Several query defaults match with key '" + JSON.stringify(queryKey) + "'. The first matching query defaults are used. Please check how query defaults are registered. Order does matter here. cf. https://react-query.tanstack.com/reference/QueryClient#queryclientsetquerydefaults.");
|
|
2063
2063
|
}
|
|
2064
2064
|
}
|
|
2065
2065
|
|
|
@@ -2092,9 +2092,7 @@ class QueryClient {
|
|
|
2092
2092
|
const matchingDefaults = this.mutationDefaults.filter(x => partialMatchKey(mutationKey, x.mutationKey)); // It is ok not having defaults, but it is error prone to have more than 1 default for a given key
|
|
2093
2093
|
|
|
2094
2094
|
if (matchingDefaults.length > 1) {
|
|
2095
|
-
|
|
2096
|
-
this.logger.error("[QueryClient] Several mutation defaults match with key '" + JSON.stringify(mutationKey) + "'. The first matching mutation defaults are used. Please check how mutation defaults are registered. Order does matter here. cf. https://react-query.tanstack.com/reference/QueryClient#queryclientsetmutationdefaults.");
|
|
2097
|
-
}
|
|
2095
|
+
this.logger.error("[QueryClient] Several mutation defaults match with key '" + JSON.stringify(mutationKey) + "'. The first matching mutation defaults are used. Please check how mutation defaults are registered. Order does matter here. cf. https://react-query.tanstack.com/reference/QueryClient#queryclientsetmutationdefaults.");
|
|
2098
2096
|
}
|
|
2099
2097
|
}
|
|
2100
2098
|
|
|
@@ -2201,6 +2199,14 @@ class QueryObserver extends Subscribable {
|
|
|
2201
2199
|
const prevQuery = this.currentQuery;
|
|
2202
2200
|
this.options = this.client.defaultQueryOptions(options);
|
|
2203
2201
|
|
|
2202
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2203
|
+
this.client.getQueryCache().notify({
|
|
2204
|
+
type: 'observerOptionsUpdated',
|
|
2205
|
+
query: this.currentQuery,
|
|
2206
|
+
observer: this
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2204
2210
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2205
2211
|
throw new Error('Expected enabled to be a boolean');
|
|
2206
2212
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2884,7 +2890,16 @@ class MutationObserver extends Subscribable {
|
|
|
2884
2890
|
}
|
|
2885
2891
|
|
|
2886
2892
|
setOptions(options) {
|
|
2893
|
+
const prevOptions = this.options;
|
|
2887
2894
|
this.options = this.client.defaultMutationOptions(options);
|
|
2895
|
+
|
|
2896
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2897
|
+
this.client.getMutationCache().notify({
|
|
2898
|
+
type: 'observerOptionsUpdated',
|
|
2899
|
+
mutation: this.currentMutation,
|
|
2900
|
+
observer: this
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2888
2903
|
}
|
|
2889
2904
|
|
|
2890
2905
|
onUnsubscribe() {
|
|
@@ -3074,4 +3089,4 @@ function hydrate(client, dehydratedState, options) {
|
|
|
3074
3089
|
}
|
|
3075
3090
|
|
|
3076
3091
|
export { CancelledError, InfiniteQueryObserver, MutationCache, MutationObserver, QueriesObserver, QueryCache, QueryClient, QueryObserver, dehydrate, focusManager, hashQueryKey, hydrate, isCancelledError, isError, notifyManager, onlineManager, parseFilterArgs, parseMutationArgs, parseMutationFilterArgs, parseQueryArgs };
|
|
3077
|
-
//# sourceMappingURL=index.
|
|
3092
|
+
//# sourceMappingURL=index.mjs.map
|