@tanstack/react-query 4.0.9 → 4.1.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/cjs/query-core/build/esm/index.js +19 -6
- package/build/cjs/query-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +19 -6
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +180 -180
- package/build/types/packages/query-core/src/mutationCache.d.ts +6 -1
- package/build/types/packages/query-core/src/queryCache.d.ts +6 -1
- package/build/umd/index.development.js +19 -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 +1 -1
- package/src/__tests__/useQuery.test.tsx +10 -8
|
@@ -2071,9 +2071,7 @@ class QueryClient {
|
|
|
2071
2071
|
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
|
|
2072
2072
|
|
|
2073
2073
|
if (matchingDefaults.length > 1) {
|
|
2074
|
-
|
|
2075
|
-
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.");
|
|
2076
|
-
}
|
|
2074
|
+
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.");
|
|
2077
2075
|
}
|
|
2078
2076
|
}
|
|
2079
2077
|
|
|
@@ -2106,9 +2104,7 @@ class QueryClient {
|
|
|
2106
2104
|
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
|
|
2107
2105
|
|
|
2108
2106
|
if (matchingDefaults.length > 1) {
|
|
2109
|
-
|
|
2110
|
-
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.");
|
|
2111
|
-
}
|
|
2107
|
+
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.");
|
|
2112
2108
|
}
|
|
2113
2109
|
}
|
|
2114
2110
|
|
|
@@ -2215,6 +2211,14 @@ class QueryObserver extends Subscribable {
|
|
|
2215
2211
|
const prevQuery = this.currentQuery;
|
|
2216
2212
|
this.options = this.client.defaultQueryOptions(options);
|
|
2217
2213
|
|
|
2214
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2215
|
+
this.client.getQueryCache().notify({
|
|
2216
|
+
type: 'observerOptionsUpdated',
|
|
2217
|
+
query: this.currentQuery,
|
|
2218
|
+
observer: this
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2218
2222
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2219
2223
|
throw new Error('Expected enabled to be a boolean');
|
|
2220
2224
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2898,7 +2902,16 @@ class MutationObserver extends Subscribable {
|
|
|
2898
2902
|
}
|
|
2899
2903
|
|
|
2900
2904
|
setOptions(options) {
|
|
2905
|
+
const prevOptions = this.options;
|
|
2901
2906
|
this.options = this.client.defaultMutationOptions(options);
|
|
2907
|
+
|
|
2908
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2909
|
+
this.client.getMutationCache().notify({
|
|
2910
|
+
type: 'observerOptionsUpdated',
|
|
2911
|
+
mutation: this.currentMutation,
|
|
2912
|
+
observer: this
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2902
2915
|
}
|
|
2903
2916
|
|
|
2904
2917
|
onUnsubscribe() {
|