@tanstack/react-query 5.0.0-alpha.10 → 5.0.0-alpha.18
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.
|
@@ -1135,10 +1135,11 @@
|
|
|
1135
1135
|
return [...this.#queries.values()];
|
|
1136
1136
|
}
|
|
1137
1137
|
find(filters) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1138
|
+
const defaultedFilters = {
|
|
1139
|
+
exact: true,
|
|
1140
|
+
...filters
|
|
1141
|
+
};
|
|
1142
|
+
return this.getAll().find(query => matchQuery(defaultedFilters, query));
|
|
1142
1143
|
}
|
|
1143
1144
|
findAll(filters = {}) {
|
|
1144
1145
|
const queries = this.getAll();
|
|
@@ -1444,10 +1445,11 @@
|
|
|
1444
1445
|
return this.#mutations;
|
|
1445
1446
|
}
|
|
1446
1447
|
find(filters) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1448
|
+
const defaultedFilters = {
|
|
1449
|
+
exact: true,
|
|
1450
|
+
...filters
|
|
1451
|
+
};
|
|
1452
|
+
return this.#mutations.find(mutation => matchMutation(defaultedFilters, mutation));
|
|
1451
1453
|
}
|
|
1452
1454
|
findAll(filters = {}) {
|
|
1453
1455
|
return this.#mutations.filter(mutation => matchMutation(filters, mutation));
|
|
@@ -1714,10 +1716,11 @@
|
|
|
1714
1716
|
});
|
|
1715
1717
|
}
|
|
1716
1718
|
cancelQueries(filters = {}, cancelOptions = {}) {
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1719
|
+
const defaultedCancelOptions = {
|
|
1720
|
+
revert: true,
|
|
1721
|
+
...cancelOptions
|
|
1722
|
+
};
|
|
1723
|
+
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map(query => query.cancel(defaultedCancelOptions)));
|
|
1721
1724
|
return Promise.all(promises).then(noop$1).catch(noop$1);
|
|
1722
1725
|
}
|
|
1723
1726
|
invalidateQueries(filters = {}, options = {}) {
|
|
@@ -2609,24 +2612,10 @@
|
|
|
2609
2612
|
return query.state.status === 'success';
|
|
2610
2613
|
}
|
|
2611
2614
|
function dehydrate(client, options = {}) {
|
|
2612
|
-
const
|
|
2613
|
-
const
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
client.getMutationCache().getAll().forEach(mutation => {
|
|
2617
|
-
if (shouldDehydrateMutation(mutation)) {
|
|
2618
|
-
mutations.push(dehydrateMutation(mutation));
|
|
2619
|
-
}
|
|
2620
|
-
});
|
|
2621
|
-
}
|
|
2622
|
-
if (options.dehydrateQueries !== false) {
|
|
2623
|
-
const shouldDehydrateQuery = options.shouldDehydrateQuery || defaultShouldDehydrateQuery;
|
|
2624
|
-
client.getQueryCache().getAll().forEach(query => {
|
|
2625
|
-
if (shouldDehydrateQuery(query)) {
|
|
2626
|
-
queries.push(dehydrateQuery(query));
|
|
2627
|
-
}
|
|
2628
|
-
});
|
|
2629
|
-
}
|
|
2615
|
+
const filterMutation = options.shouldDehydrateMutation ?? defaultShouldDehydrateMutation;
|
|
2616
|
+
const mutations = client.getMutationCache().getAll().flatMap(mutation => filterMutation(mutation) ? [dehydrateMutation(mutation)] : []);
|
|
2617
|
+
const filterQuery = options.shouldDehydrateQuery ?? defaultShouldDehydrateQuery;
|
|
2618
|
+
const queries = client.getQueryCache().getAll().flatMap(query => filterQuery(query) ? [dehydrateQuery(query)] : []);
|
|
2630
2619
|
return {
|
|
2631
2620
|
mutations,
|
|
2632
2621
|
queries
|