Skip to content

fix(vue-query): widen 'queryOptions' input to match 'useQuery' - #11439

Open
tinas wants to merge 1 commit into
TanStack:mainfrom
tinas:fix/vue-query-query-options-input
Open

fix(vue-query): widen 'queryOptions' input to match 'useQuery'#11439
tinas wants to merge 1 commit into
TanStack:mainfrom
tinas:fix/vue-query-query-options-input

Conversation

@tinas

@tinas tinas commented Sep 6, 2026

Copy link
Copy Markdown

🎯 Changes

Options that work inline in useQuery could not be extracted into queryOptions:

// works
useQuery({ queryKey, queryFn: computed(() => name.value ? fetchFn : skipToken) })

// did not type check
queryOptions({ queryKey, queryFn: computed(() => name.value ? fetchFn : skipToken) })

Reproduction: https://codesandbox.io/p/devbox/2yzjz5

queryOptions now accepts everything useQuery accepts. What it returns is unchanged.

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

    • Query options now support reactive getters for entire query keys.
    • Query functions can dynamically use skipToken through refs, computed values, and option getters.
    • Improved type inference is preserved for conditionally skipped queries.
  • Documentation

    • Updated query option guidance to clarify reactivity behavior for query keys and other options.

@coderabbitai

coderabbitai Bot commented Sep 6, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 3574b261-993b-4899-a77d-8146ed1cd49c

📥 Commits

Reviewing files that changed from the base of the PR and between a1119e5 and 858560e.

📒 Files selected for processing (9)
  • packages/vue-query/src/__tests__/queryOptions.test-d.ts
  • packages/vue-query/src/__tests__/useQueries.test-d.ts
  • packages/vue-query/src/__tests__/useQuery.test-d.ts
  • packages/vue-query/src/index.ts
  • packages/vue-query/src/queryClient.ts
  • packages/vue-query/src/queryOptions.ts
  • packages/vue-query/src/useBaseQuery.ts
  • packages/vue-query/src/useQueries.ts
  • packages/vue-query/src/useQuery.ts

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


📝 Walkthrough

Walkthrough

Vue Query now models reactive query options with MaybeRef and MaybeRefDeep. skipToken is supported in reactive query functions and option getters. Query option types moved to queryOptions, and type tests cover the updated behavior.

Changes

Vue Query reactivity types

Layer / File(s) Summary
Reactive option type definitions
packages/vue-query/src/queryOptions.ts
Adds UseQueryOptions, skipToken query function support, and reusable initial-data helper types.
Type relocation and API wiring
packages/vue-query/src/queryOptions.ts, packages/vue-query/src/useQuery.ts, packages/vue-query/src/index.ts, packages/vue-query/src/queryClient.ts, packages/vue-query/src/useBaseQuery.ts, packages/vue-query/src/useQueries.ts
Moves option type definitions to queryOptions, updates internal imports, and documents getter-based query key and reactive option behavior.
Reactive option type tests
packages/vue-query/src/__tests__/*.test-d.ts
Adds coverage for skipToken in computed query functions and whole-options getters, and accepts getter-based query keys.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 85856

The Vue Query option types and public exports remain consistent with the intended reactive query-function behavior, with no current merge-blocking risk identified.

Suggested reviewers: sukvvon, tkdodo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the motivation, provides a reproduction, and completes the checklist. The Release Impact section is incomplete because neither option is selected, although the changes affect … Add a changeset and select the published-code option, or explain why this change is not release-impacting and select the docs/CI/dev-only option if that is correct.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: widening the queryOptions input to match useQuery.
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 9…
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.
Full details: Description check

Explanation

The description explains the motivation, provides a reproduction, and completes the checklist. The Release Impact section is incomplete because neither option is selected, although the changes affect published type exports.

  • Fix all pre-merge checks with AI
✨ 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.

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