Skip to content

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

Open
byungsker wants to merge 2 commits into
TanStack:mainfrom
byungsker:fix/vue-query-client-getter-options
Open

fix(vue-query): unwrap getter options in fetchQuery#11103
byungsker wants to merge 2 commits into
TanStack:mainfrom
byungsker:fix/vue-query-client-getter-options

Conversation

@byungsker

@byungsker byungsker commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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 97ce30b and b7cdf5c.

📒 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)
Loading

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 name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: unwrapping getter options in Vue Query fetchQuery.
Description check ✅ Passed The description explains the bug, implementation, tests, checklist, release impact, and changeset status.
Linked Issues check ✅ Passed The 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 ✅ Passed All changes support issue [#11102] and the stated fetchQuery getter-unwrapping objective; no unrelated code changes are present.
Docstring Coverage ✅ Passed No 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 86bb8a6 and 3d73409.

📒 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

Comment thread packages/vue-query/src/queryClient.ts
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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.

@nx-cloud

nx-cloud Bot commented Aug 20, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b7cdf5c

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 5m 31s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 10s View ↗

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown
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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vue-query] queryClient.fetchQuery passes getter options through without unwrapping

2 participants