Skip to content
Source
Sign inSign up
TanStack/query

fix(vue-query): unwrap getter options in fetchQuery #11103

Openbyungsker(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/11103/headopened View on GitHub

Fixes #11102

🎯 Changes

QueryClient.fetchQuery has an overload that accepts a getter function returning FetchQueryOptions, but the runtime path passed that top-level function directly to query-core.

This PR evaluates top-level getter options before applying the existing deep-unref behavior.

Changes included:

  • Add a small helper to unwrap top-level getter options before cloneDeepUnref
  • Use it in queryClient.fetchQuery
  • Add regression coverage for fetchQuery(() => options)
  • Add a patch changeset for @tanstack/vue-query

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

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

Tests

  • pnpm run test:pr
  • pnpm nx run @tanstack/vue-query:test:lib -- queryClient.test.ts
  • pnpm nx run @tanstack/vue-query:test:types
  • pnpm nx run @tanstack/vue-query:test:eslint
  • pnpm exec prettier --check .changeset/vue-query-fetch-query-getter-options.md packages/vue-query/src/queryClient.ts packages/vue-query/src/__tests__/queryClient.test.ts

Summary by CodeRabbit

  • New Features

    • fetchQuery now accepts getter functions that return query options.
    • Getter-based options are evaluated and reactive values are automatically unwrapped before fetching data.
  • Bug Fixes

    • Improved compatibility when using reactive or computed query options with fetchQuery.
  • Documentation

    • Added a patch release note for the Vue Query package.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 27fc20d3-d5d5-429d-8cd4-abf9cff4e77b

      📥 Commits

      Reviewing files that changed from the base of the PR and between 97ce30b51e3040752f3f4172e9fd11be4edea774 and b7cdf5ca95413090a66d25801b3a8fa932b6cfca.

      📒 Files selected for processing (3)
      • .changeset/vue-query-fetch-query-getter-options.md
      • packages/vue-query/src/__tests__/queryClient.test.ts
      • packages/vue-query/src/queryClient.ts
      🚧 Files skipped from review as they are similar to previous changes (3)
      • .changeset/vue-query-fetch-query-getter-options.md
      • packages/vue-query/src/tests/queryClient.test.ts
      • packages/vue-query/src/queryClient.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


      📝 Walkthrough

      Walkthrough

      @tanstack/vue-query now evaluates getter functions passed to fetchQuery, deep-unrefs the returned options, forwards them to query-core, and adds regression coverage plus a patch Changesets entry.

      Changes

      Fetch query getter options

      Layer / File(s)Summary
      Resolve and clone getter options
      packages/vue-query/src/queryClient.ts
      Adds a getter-aware option type and helper. Updates fetchQuery to evaluate and deep-unref getter-provided options before delegation.
      Validate and release the behavior
      packages/vue-query/src/__tests__/queryClient.test.ts, .changeset/vue-query-fetch-query-getter-options.md
      Tests that query-core receives unwrapped options. Records a patch release describing the behavior change.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Merge Risk: ⚪ Minimal · up to b7cdf

      This localized fix evaluates getter-based options before fetching and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review.

      Sequence Diagram(s)

      sequenceDiagram
        participant Caller
        participant VueQueryQueryClient
        participant QueryClientOrigin
        Caller->>VueQueryQueryClient: fetchQuery(getter)
        VueQueryQueryClient->>VueQueryQueryClient: evaluate getter and deep-unref options
        VueQueryQueryClient->>QueryClientOrigin: fetchQuery(unwrapped options)

      Possibly related PRs

      • TanStack/query#11108: Both PRs modify fetchQuery to evaluate getter-function options and deep-unref them before delegation.

      Suggested labels: package: vue-query

      Suggested reviewers: tkdodo

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the primary fix: unwrapping getter options in Vue Query fetchQuery.
      Description check✅ PassedThe description explains the bug, implementation, tests, checklist, release impact, and changeset status.
      Linked Issues check✅ PassedThe changes evaluate top-level getter options, deep-unref the result, add regression coverage, and provide the required patch changeset for issue [#11102].
      Out of Scope Changes check✅ PassedAll changes support issue [#11102] and the stated fetchQuery getter-unwrapping objective; no unrelated code changes are present.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. Actionable comments posted: 1

      🤖 Prompt for all review comments with AI agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      Inline comments:
      In `@packages/vue-query/src/queryClient.ts`:
      - Around line 36-41: Update the fetchQuery overload’s getter branch to accept ()
      => MaybeRefDeep<FetchQueryOptions<...>> instead of only () =>
      FetchQueryOptions<...>, matching cloneDeepUnrefOrGet runtime support for
      ref-bearing options while preserving the existing non-getter overload behavior.
      🪄 Autofix (Beta)

      Fix all unresolved CodeRabbit comments on this PR:

      • Push a commit to this branch (recommended)
      • Create a new PR with the fixes

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 74cf3a52-8bdf-4c55-9ef2-fac18a9d7107

      📥 Commits

      Reviewing files that changed from the base of the PR and between 86bb8a6fb2c7f15c74ff50afba053d778e6edc23 and 3d7340986a9950cdc1db42a43c080fd19241271a.

      📒 Files selected for processing (3)
      • .changeset/vue-query-fetch-query-getter-options.md
      • packages/vue-query/src/__tests__/queryClient.test.ts
      • packages/vue-query/src/queryClient.ts
    3. Note

      GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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

      View your CI Pipeline Execution ↗ for commit b7cdf5ca95413090a66d25801b3a8fa932b6cfca

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

      ☁️ Nx Cloud last updated this comment at 2026-08-20 15:25:50 UTC

    5. More templates

      @tanstack/angular-query-experimental

      npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11103

      @tanstack/eslint-plugin-query

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11103

      @tanstack/lit-query

      npm i https://pkg.pr.new/@tanstack/lit-query@11103

      @tanstack/preact-query

      npm i https://pkg.pr.new/@tanstack/preact-query@11103

      @tanstack/preact-query-devtools

      npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11103

      @tanstack/preact-query-persist-client

      npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11103

      @tanstack/query-async-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11103

      @tanstack/query-broadcast-client-experimental

      npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11103

      @tanstack/query-core

      npm i https://pkg.pr.new/@tanstack/query-core@11103

      @tanstack/query-devtools

      npm i https://pkg.pr.new/@tanstack/query-devtools@11103

      @tanstack/query-persist-client-core

      npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11103

      @tanstack/query-sync-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11103

      @tanstack/react-query

      npm i https://pkg.pr.new/@tanstack/react-query@11103

      @tanstack/react-query-devtools

      npm i https://pkg.pr.new/@tanstack/react-query-devtools@11103

      @tanstack/react-query-next-experimental

      npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11103

      @tanstack/react-query-persist-client

      npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11103

      @tanstack/solid-query

      npm i https://pkg.pr.new/@tanstack/solid-query@11103

      @tanstack/solid-query-devtools

      npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11103

      @tanstack/solid-query-persist-client

      npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11103

      @tanstack/svelte-query

      npm i https://pkg.pr.new/@tanstack/svelte-query@11103

      @tanstack/svelte-query-devtools

      npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11103

      @tanstack/svelte-query-persist-client

      npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11103

      @tanstack/vue-query

      npm i https://pkg.pr.new/@tanstack/vue-query@11103

      @tanstack/vue-query-devtools

      npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11103

      commit: b7cdf5c

Sign in to join this conversation.