@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.
@@ -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
- if (process.env.NODE_ENV !== 'production') {
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
- if (process.env.NODE_ENV !== 'production') {
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() {