@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
package/build/esm/index.js
CHANGED
|
@@ -2070,9 +2070,7 @@ class QueryClient {
|
|
|
2070
2070
|
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
|
|
2071
2071
|
|
|
2072
2072
|
if (matchingDefaults.length > 1) {
|
|
2073
|
-
|
|
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.");
|
|
2075
|
-
}
|
|
2073
|
+
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
|
}
|
|
2077
2075
|
}
|
|
2078
2076
|
|
|
@@ -2105,9 +2103,7 @@ class QueryClient {
|
|
|
2105
2103
|
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
|
|
2106
2104
|
|
|
2107
2105
|
if (matchingDefaults.length > 1) {
|
|
2108
|
-
|
|
2109
|
-
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.");
|
|
2110
|
-
}
|
|
2106
|
+
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
|
}
|
|
2112
2108
|
}
|
|
2113
2109
|
|
|
@@ -2214,6 +2210,14 @@ class QueryObserver extends Subscribable {
|
|
|
2214
2210
|
const prevQuery = this.currentQuery;
|
|
2215
2211
|
this.options = this.client.defaultQueryOptions(options);
|
|
2216
2212
|
|
|
2213
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2214
|
+
this.client.getQueryCache().notify({
|
|
2215
|
+
type: 'observerOptionsUpdated',
|
|
2216
|
+
query: this.currentQuery,
|
|
2217
|
+
observer: this
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2217
2221
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2218
2222
|
throw new Error('Expected enabled to be a boolean');
|
|
2219
2223
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2897,7 +2901,16 @@ class MutationObserver extends Subscribable {
|
|
|
2897
2901
|
}
|
|
2898
2902
|
|
|
2899
2903
|
setOptions(options) {
|
|
2904
|
+
const prevOptions = this.options;
|
|
2900
2905
|
this.options = this.client.defaultMutationOptions(options);
|
|
2906
|
+
|
|
2907
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2908
|
+
this.client.getMutationCache().notify({
|
|
2909
|
+
type: 'observerOptionsUpdated',
|
|
2910
|
+
mutation: this.currentMutation,
|
|
2911
|
+
observer: this
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2901
2914
|
}
|
|
2902
2915
|
|
|
2903
2916
|
onUnsubscribe() {
|