@tanstack/vue-query 5.0.0-alpha.10 → 5.0.0-alpha.12

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.
@@ -2590,24 +2590,10 @@
2590
2590
  return query.state.status === 'success';
2591
2591
  }
2592
2592
  function dehydrate(client, options = {}) {
2593
- const mutations = [];
2594
- const queries = [];
2595
- if (options.dehydrateMutations !== false) {
2596
- const shouldDehydrateMutation = options.shouldDehydrateMutation || defaultShouldDehydrateMutation;
2597
- client.getMutationCache().getAll().forEach(mutation => {
2598
- if (shouldDehydrateMutation(mutation)) {
2599
- mutations.push(dehydrateMutation(mutation));
2600
- }
2601
- });
2602
- }
2603
- if (options.dehydrateQueries !== false) {
2604
- const shouldDehydrateQuery = options.shouldDehydrateQuery || defaultShouldDehydrateQuery;
2605
- client.getQueryCache().getAll().forEach(query => {
2606
- if (shouldDehydrateQuery(query)) {
2607
- queries.push(dehydrateQuery(query));
2608
- }
2609
- });
2610
- }
2593
+ const filterMutation = options.shouldDehydrateMutation ?? defaultShouldDehydrateMutation;
2594
+ const mutations = client.getMutationCache().getAll().flatMap(mutation => filterMutation(mutation) ? [dehydrateMutation(mutation)] : []);
2595
+ const filterQuery = options.shouldDehydrateQuery ?? defaultShouldDehydrateQuery;
2596
+ const queries = client.getQueryCache().getAll().flatMap(query => filterQuery(query) ? [dehydrateQuery(query)] : []);
2611
2597
  return {
2612
2598
  mutations,
2613
2599
  queries