@tanstack/react-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.
@@ -2609,24 +2609,10 @@
2609
2609
  return query.state.status === 'success';
2610
2610
  }
2611
2611
  function dehydrate(client, options = {}) {
2612
- const mutations = [];
2613
- const queries = [];
2614
- if (options.dehydrateMutations !== false) {
2615
- const shouldDehydrateMutation = options.shouldDehydrateMutation || defaultShouldDehydrateMutation;
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
- }
2612
+ const filterMutation = options.shouldDehydrateMutation ?? defaultShouldDehydrateMutation;
2613
+ const mutations = client.getMutationCache().getAll().flatMap(mutation => filterMutation(mutation) ? [dehydrateMutation(mutation)] : []);
2614
+ const filterQuery = options.shouldDehydrateQuery ?? defaultShouldDehydrateQuery;
2615
+ const queries = client.getQueryCache().getAll().flatMap(query => filterQuery(query) ? [dehydrateQuery(query)] : []);
2630
2616
  return {
2631
2617
  mutations,
2632
2618
  queries