Skip to content

fix(vue-query/queryClient): infer the data and error types of 'getQueryState' from a tagged query key - #11921

Open
sukvvon wants to merge 2 commits into
mainfrom
fix/vue-query-get-query-state-tagged-key
Open

sukvvon wants to merge 2 commits into
mainfrom
fix/vue-query-get-query-state-tagged-key

Conversation

@sukvvon

@sukvvon sukvvon commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

The getQueryState override in vue-query's QueryClient only had the MaybeRefDeep<QueryKey> signature, so a key tagged by queryOptions gave QueryState<unknown, Error>, unlike getQueryData and the query-core getQueryState.

const { queryKey } = queryOptions({ queryKey: ['key'], queryFn: () => 5 })

queryClient.getQueryData(queryKey) // number | undefined
queryClient.getQueryState(queryKey)?.data // before: unknown, after: number | undefined
  • Add an overload that infers the data and error types from a tagged key, with the same signature as query-core, and keep the MaybeRefDeep<QueryKey> signature for ref keys.
  • Add type tests for a tagged key (data and error), an untagged key, an explicit generic, a ref key, and a queryOptions key.
  • Regenerate the vue reference docs for the new overloads.

✅ 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).

Summary by CodeRabbit

  • New Features
    • getQueryState now infers the query’s data and error types from tagged query keys, improving type information when accessing query state.
  • Documentation
    • Updated the Vue QueryClient reference to describe the tagged-key overload and its inferred types.

@sukvvon sukvvon self-assigned this Oct 6, 2026
@changeset-bot

changeset-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 07c73fc

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

This PR includes changesets to release 24 packages
Name Type
@tanstack/vue-query Patch
@tanstack/vue-query-devtools Patch
@tanstack/angular-query-experimental Patch
@tanstack/eslint-plugin-query Patch
@tanstack/preact-query-devtools Patch
@tanstack/preact-query-persist-client Patch
@tanstack/preact-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-core Patch
@tanstack/query-devtools Patch
@tanstack/query-persist-client-core Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/react-query-devtools Patch
@tanstack/react-query-next-experimental Patch
@tanstack/react-query-persist-client Patch
@tanstack/react-query Patch
@tanstack/solid-query-devtools Patch
@tanstack/solid-query-persist-client Patch
@tanstack/solid-query Patch
@tanstack/lit-query Patch
@tanstack/svelte-query Patch
@tanstack/svelte-query-devtools Patch
@tanstack/svelte-query-persist-client Patch

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

@nx-cloud

nx-cloud Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 07c73fc

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

☁️ Nx Cloud last updated this comment at 2026-10-06 12:49:43 UTC

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

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

🟩 Patch bumps

Package Version Reason
@tanstack/query-core 5.104.1 → 5.104.2 Changeset
@tanstack/vue-query 5.104.1 → 5.104.2 Changeset
@tanstack/angular-query-experimental 5.104.1 → 5.104.2 Dependent
@tanstack/angular-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/eslint-plugin-query 5.104.1 → 5.104.2 Dependent
@tanstack/lit-query 0.2.26 → 0.2.27 Dependent
@tanstack/preact-query 5.104.1 → 5.104.2 Dependent
@tanstack/preact-query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/preact-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/query-async-storage-persister 5.104.1 → 5.104.2 Dependent
@tanstack/query-broadcast-client-experimental 5.104.1 → 5.104.2 Dependent
@tanstack/query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/query-persist-client-core 5.104.1 → 5.104.2 Dependent
@tanstack/query-sync-storage-persister 5.104.1 → 5.104.2 Dependent
@tanstack/react-query 5.104.1 → 5.104.2 Dependent
@tanstack/react-query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/react-query-next-experimental 5.104.1 → 5.104.2 Dependent
@tanstack/react-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/solid-query 5.104.1 → 5.104.2 Dependent
@tanstack/solid-query-devtools 5.104.1 → 5.104.2 Dependent
@tanstack/solid-query-persist-client 5.104.1 → 5.104.2 Dependent
@tanstack/svelte-query 6.3.1 → 6.3.2 Dependent
@tanstack/svelte-query-devtools 6.3.1 → 6.3.2 Dependent
@tanstack/svelte-query-persist-client 6.3.1 → 6.3.2 Dependent
@tanstack/vue-query-devtools 6.3.1 → 6.3.2 Dependent

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/query/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93d6184c-0d35-44ad-ade6-7897517274c1
📥 Commits

Reviewing files that changed from the base of the PR and between d169ee8 and 07c73fc.

📒 Files selected for processing (5)
  • .changeset/tidy-states-infer.md
  • docs/framework/vue/reference/classes/QueryClient.md
  • packages/vue-query/src/__tests__/queryClient.test-d.ts
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/queryClient.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

QueryClient.getQueryState now infers data and error types from tagged query keys. Type tests cover the overload, and the Vue reference documents it and refreshes source links.

Changes

Vue Query State Type Inference

Layer / File(s) Summary
Add tagged-key type inference
packages/vue-query/src/queryClient.ts, packages/vue-query/src/__tests__/queryClient.test-d.ts, packages/vue-query/src/__tests__/queryOptions.test-d.ts, .changeset/tidy-states-infer.md
getQueryState adds a tagged-key overload that infers data and error types. Type tests cover tagged and untagged keys, custom errors, explicit data generics, and ref-wrapped keys.
Update QueryClient reference
docs/framework/vue/reference/classes/QueryClient.md
The reference documents the tagged-key overload and updates Defined in source links.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: dogpawhat

Merge Risk: ⚪ Minimal · up to 07c73

The type-inference fix is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Vue Query getQueryState type-inference change for tagged query keys.
Description check ✅ Passed The description follows the required template. It explains the change and motivation, completes the checklist, and identifies the release impact and changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 6, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 07c73fc

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.73 KB (0%)
react minimal 8.58 KB (0%)

This branch has not been deployed

No deployments
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.

1 participant