@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
|
@@ -27,12 +27,17 @@ interface NotifyEventMutationObserverRemoved {
|
|
|
27
27
|
mutation: Mutation<any, any, any, any>;
|
|
28
28
|
observer: MutationObserver<any, any, any>;
|
|
29
29
|
}
|
|
30
|
+
interface NotifyEventMutationObserverOptionsUpdated {
|
|
31
|
+
type: 'observerOptionsUpdated';
|
|
32
|
+
mutation?: Mutation<any, any, any, any>;
|
|
33
|
+
observer: MutationObserver<any, any, any, any>;
|
|
34
|
+
}
|
|
30
35
|
interface NotifyEventMutationUpdated {
|
|
31
36
|
type: 'updated';
|
|
32
37
|
mutation: Mutation<any, any, any, any>;
|
|
33
38
|
action: Action<any, any, any, any>;
|
|
34
39
|
}
|
|
35
|
-
declare type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationUpdated;
|
|
40
|
+
declare type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationObserverOptionsUpdated | NotifyEventMutationUpdated;
|
|
36
41
|
declare type MutationCacheListener = (event: MutationCacheNotifyEvent) => void;
|
|
37
42
|
export declare class MutationCache extends Subscribable<MutationCacheListener> {
|
|
38
43
|
config: MutationCacheConfig;
|
|
@@ -35,7 +35,12 @@ interface NotifyEventQueryObserverResultsUpdated {
|
|
|
35
35
|
type: 'observerResultsUpdated';
|
|
36
36
|
query: Query<any, any, any, any>;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
interface NotifyEventQueryObserverOptionsUpdated {
|
|
39
|
+
type: 'observerOptionsUpdated';
|
|
40
|
+
query: Query<any, any, any, any>;
|
|
41
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
42
|
+
}
|
|
43
|
+
declare type QueryCacheNotifyEvent = NotifyEventQueryAdded | NotifyEventQueryRemoved | NotifyEventQueryUpdated | NotifyEventQueryObserverAdded | NotifyEventQueryObserverRemoved | NotifyEventQueryObserverResultsUpdated | NotifyEventQueryObserverOptionsUpdated;
|
|
39
44
|
declare type QueryCacheListener = (event: QueryCacheNotifyEvent) => void;
|
|
40
45
|
export declare class QueryCache extends Subscribable<QueryCacheListener> {
|
|
41
46
|
config: QueryCacheConfig;
|
|
@@ -2093,9 +2093,7 @@
|
|
|
2093
2093
|
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
|
|
2094
2094
|
|
|
2095
2095
|
if (matchingDefaults.length > 1) {
|
|
2096
|
-
|
|
2097
|
-
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.");
|
|
2098
|
-
}
|
|
2096
|
+
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.");
|
|
2099
2097
|
}
|
|
2100
2098
|
}
|
|
2101
2099
|
|
|
@@ -2128,9 +2126,7 @@
|
|
|
2128
2126
|
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
|
|
2129
2127
|
|
|
2130
2128
|
if (matchingDefaults.length > 1) {
|
|
2131
|
-
|
|
2132
|
-
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.");
|
|
2133
|
-
}
|
|
2129
|
+
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.");
|
|
2134
2130
|
}
|
|
2135
2131
|
}
|
|
2136
2132
|
|
|
@@ -2237,6 +2233,14 @@
|
|
|
2237
2233
|
const prevQuery = this.currentQuery;
|
|
2238
2234
|
this.options = this.client.defaultQueryOptions(options);
|
|
2239
2235
|
|
|
2236
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2237
|
+
this.client.getQueryCache().notify({
|
|
2238
|
+
type: 'observerOptionsUpdated',
|
|
2239
|
+
query: this.currentQuery,
|
|
2240
|
+
observer: this
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2240
2244
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2241
2245
|
throw new Error('Expected enabled to be a boolean');
|
|
2242
2246
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2920,7 +2924,16 @@
|
|
|
2920
2924
|
}
|
|
2921
2925
|
|
|
2922
2926
|
setOptions(options) {
|
|
2927
|
+
const prevOptions = this.options;
|
|
2923
2928
|
this.options = this.client.defaultMutationOptions(options);
|
|
2929
|
+
|
|
2930
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2931
|
+
this.client.getMutationCache().notify({
|
|
2932
|
+
type: 'observerOptionsUpdated',
|
|
2933
|
+
mutation: this.currentMutation,
|
|
2934
|
+
observer: this
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2924
2937
|
}
|
|
2925
2938
|
|
|
2926
2939
|
onUnsubscribe() {
|