Skip to content
Source
Sign inSign up
TanStack/query

refactor(query-core)!: create mutation caches on demand #12685

ClosedTkDodowants to merge 1 commit intoquery-v6 fromrefs/pull/12685/headopened View on GitHub

TkDodocommented

🎯 Changes

  • Use the exported getMutationCache(queryClient) function in place of queryClient.getMutationCache(). The core client creates its default cache on first access. Injected caches and Vue Query's default Vue-aware cache still work.
  • Simplify mutation scope lookup and removal. Each scope keeps its own ordered queue.
  • Update adapters, Devtools, and persistence to use the new accessor. Test that reading mutation state, dehydrating, resuming, and clearing an unused client leave the cache uninitialized.

With pnpm test:size, React minimal drops from 8,396 B to 8,066 B. React full grows from 12,694 B to 12,723 B and stays 277 B under its limit.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).
    1. 🦋 Changeset detected

      Latest commit: 1f80109047d5233333fba4c7cf2f3c9a4d212a22

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 25 packages
      NameType
      @tanstack/angular-queryMajor
      @tanstack/lit-queryMajor
      @tanstack/preact-queryMajor
      @tanstack/query-coreMajor
      @tanstack/react-queryMajor
      @tanstack/solid-queryMajor
      @tanstack/svelte-queryMajor
      @tanstack/vue-queryMajor
      @tanstack/angular-query-devtoolsMajor
      @tanstack/angular-query-persist-clientMajor
      @tanstack/preact-query-devtoolsMajor
      @tanstack/preact-query-persist-clientMajor
      @tanstack/query-async-storage-persisterMajor
      @tanstack/query-broadcast-client-experimentalMajor
      @tanstack/query-devtoolsMajor
      @tanstack/query-persist-client-coreMajor
      @tanstack/react-query-devtoolsMajor
      @tanstack/react-query-next-experimentalMajor
      @tanstack/react-query-persist-clientMajor
      @tanstack/solid-query-devtoolsMajor
      @tanstack/solid-query-persist-clientMajor
      @tanstack/svelte-query-devtoolsMajor
      @tanstack/svelte-query-persist-clientMajor
      @tanstack/vue-query-devtoolsMajor
      @tanstack/eslint-plugin-queryMajor

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. Important

      Draft PR not reviewed

      Draft PRs are not automatically reviewed by default.

      • Trigger a manual review

      To automatically review draft PRs, update your CodeRabbit configuration:

      reviews:
        auto_review:
          drafts: true
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share

    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 1f80109047d5233333fba4c7cf2f3c9a4d212a22

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded8m 28sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded35sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-11-23 12:45:38 UTC

    4. TkDodo closed this

    5. size-limit report 📦

      PathSize
      react full12.42 KB (+0.23% 🔺)
      react minimal7.88 KB (-3.94% 🔽)
    6. 🚀 Changeset Version Preview

      23 package(s) bumped directly, 2 bumped as dependents.

      🟥 Major bumps

      PackageVersionReason
      @tanstack/angular-query5.108.3 → 6.0.0Changeset
      @tanstack/angular-query-devtools5.108.3 → 6.0.0Changeset
      @tanstack/eslint-plugin-query5.108.3 → 6.0.0Changeset
      @tanstack/lit-query0.2.43 → 1.0.0Changeset
      @tanstack/preact-query5.108.3 → 6.0.0Changeset
      @tanstack/preact-query-devtools5.108.3 → 6.0.0Changeset
      @tanstack/preact-query-persist-client5.108.3 → 6.0.0Changeset
      @tanstack/query-async-storage-persister5.108.3 → 6.0.0Changeset
      @tanstack/query-broadcast-client-experimental5.108.3 → 6.0.0Changeset
      @tanstack/query-core5.108.3 → 6.0.0Changeset
      @tanstack/query-devtools5.108.3 → 6.0.0Changeset
      @tanstack/query-persist-client-core5.108.3 → 6.0.0Changeset
      @tanstack/react-query5.108.3 → 6.0.0Changeset
      @tanstack/react-query-devtools5.108.3 → 6.0.0Changeset
      @tanstack/react-query-next-experimental5.108.3 → 6.0.0Changeset
      @tanstack/react-query-persist-client5.108.3 → 6.0.0Changeset
      @tanstack/solid-query5.108.3 → 6.0.0Changeset
      @tanstack/solid-query-devtools5.108.3 → 6.0.0Changeset
      @tanstack/solid-query-persist-client5.108.3 → 6.0.0Changeset
      @tanstack/svelte-query6.4.6 → 7.0.0Changeset
      @tanstack/svelte-query-devtools6.4.6 → 7.0.0Changeset
      @tanstack/vue-query5.108.3 → 6.0.0Changeset
      @tanstack/vue-query-devtools6.4.6 → 7.0.0Changeset
      @tanstack/angular-query-persist-client5.108.3 → 6.0.0Dependent
      @tanstack/svelte-query-persist-client6.4.6 → 7.0.0Dependent

Sign in to join this conversation.