fix(vue-query): fix type of queryOptions to allow plain properies or getters #10452
main fromrefs/pull/10452/head·merged by DamianOsipiuk(GitHub profile, opens in a new tab) View on GitHub🎯 Changes#
Fixes: https://github.com/TanStack/query/issues/7892
✅ 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).
Summary by CodeRabbit#
Bug Fixes
- Fixed queryOptions typing to accept plain properties and/or getter factories.
New Features
- Exposed new QueryOptions types (including variants for required/optional initial data).
- QueryClient methods and fetchQuery now accept reactive values or zero-arg factory functions.
- Improved TypeScript inference for queryOptions and useQueries.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: vue-query
View your CI Pipeline Execution ↗ for commit 0649ccb030238f990ada9274cba6706dc0716efa
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 1m 21s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded <1s View ↗
☁️ Nx Cloud last updated this comment at
2026-04-11 15:53:44UTC🚀 Changeset Version Preview#
2 package(s) bumped directly, 22 bumped as dependents.
🟨 Minor bumps#
Package Version Reason @tanstack/vue-query5.97.0 → 5.98.0 Changeset @tanstack/angular-query-experimental5.97.0 → 5.98.0 Dependent @tanstack/angular-query-persist-client5.97.0 → 5.98.0 Dependent @tanstack/eslint-plugin-query5.97.0 → 5.98.0 Dependent @tanstack/preact-query5.97.0 → 5.98.0 Dependent @tanstack/preact-query-devtools5.97.0 → 5.98.0 Dependent @tanstack/preact-query-persist-client5.97.0 → 5.98.0 Dependent @tanstack/query-async-storage-persister5.97.0 → 5.98.0 Dependent @tanstack/query-broadcast-client-experimental5.97.0 → 5.98.0 Dependent @tanstack/query-core5.97.0 → 5.98.0 Dependent @tanstack/query-devtools5.97.0 → 5.98.0 Dependent @tanstack/query-persist-client-core5.97.0 → 5.98.0 Dependent @tanstack/query-sync-storage-persister5.97.0 → 5.98.0 Dependent @tanstack/react-query5.97.0 → 5.98.0 Dependent @tanstack/react-query-devtools5.97.0 → 5.98.0 Dependent @tanstack/react-query-next-experimental5.97.0 → 5.98.0 Dependent @tanstack/react-query-persist-client5.97.0 → 5.98.0 Dependent @tanstack/solid-query5.97.0 → 5.98.0 Dependent @tanstack/solid-query-devtools5.97.0 → 5.98.0 Dependent @tanstack/solid-query-persist-client5.97.0 → 5.98.0 Dependent 🟩 Patch bumps#
Package Version Reason @tanstack/vue-query-devtools6.1.14 → 6.1.15 Changeset @tanstack/svelte-query6.1.14 → 6.1.15 Dependent @tanstack/svelte-query-devtools6.1.14 → 6.1.15 Dependent @tanstack/svelte-query-persist-client6.1.14 → 6.1.15 Dependent Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/vue-query/src/queryClient.ts (1)
304-310: ⚠️ Potential issue | 🔴 CriticalImplementation signature and body don't handle getter functions.
The overload (lines 286-296) accepts
(() => FetchQueryOptions<...>), but the implementation signature (lines 305-307) only declaresMaybeRefDeep<FetchQueryOptions<...>>. When a getter is passed, it will be mishandled bycloneDeepUnrefthe same way as ininvalidateQueries.🐛 Proposed fix to handle getters in fetchQuery
fetchQuery< TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never, >( - options: MaybeRefDeep< - FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> - >, + options: + | MaybeRefDeep< + FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> + > + | (() => FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>), ): Promise<TData> { - return super.fetchQuery(cloneDeepUnref(options)) + return super.fetchQuery( + cloneDeepUnref( + toValueDeep(options) as MaybeRefDeep< + FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> + >, + ), + ) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/queryClient.ts` around lines 304 - 310, The implementation of fetchQuery doesn't handle getter functions even though an overload accepts (() => FetchQueryOptions<...>); update the implementation signature to accept either a getter or MaybeRefDeep (e.g., options: MaybeRefDeep<FetchQueryOptions<...>> | (() => FetchQueryOptions<...>)) and inside fetchQuery resolve the getter before cloning: detect if options is a function (the getter) and call it to obtain the options, then pass the resolved value to cloneDeepUnref and forward to super.fetchQuery; reference fetchQuery and cloneDeepUnref to locate where to change.🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Inline comments: In @.changeset/three-pillows-enter.md: - Line 5: Typo in the changeset title string "fix(vue-query): fix type of queryOptions to allow plain properies or getters" — change "properies" to "properties" so the sentence reads "...allow plain properties or getters"; update that exact text in the .changeset entry to correct the spelling. In `@packages/vue-query/src/queryClient.ts`: - Line 3: The file imports toValueDeep but never uses it; update the call sites where query keys or args are processed (notably in functions/methods named invalidateQueries and fetchQuery) to resolve getter functions before deep-unwrapping by passing inputs through toValueDeep and then into cloneDeepUnref (e.g., replace direct cloneDeepUnref(someInput) with cloneDeepUnref(toValueDeep(someInput))). This ensures getter-based keys/params are evaluated prior to cloning and keeps the existing import usage. - Around line 205-209: The public overload for invalidateQueries in queryClient.ts is missing getter support for the options parameter; update the overload’s options type to include a getter by changing options?: MaybeRefDeep<InvalidateOptions> to options?: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions) (or (() => MaybeRefDeep<InvalidateOptions>) to match your ref handling) so the public signature matches the implementation that accepts (() => InvalidateOptions); adjust the overload for invalidateQueries and ensure references to InvalidateOptions and MaybeRefDeep remain consistent. - Around line 216-221: The code currently passes potential getter functions directly into cloneDeepUnref (e.g., when building filtersCloned and optionsCloned), but cloneDeepUnref(unrefGetters=false) won't invoke root-level getters so function objects slip through; fix by first resolving any getters with toValueDeep on the original inputs (filters and options) and then pass the resolved values into cloneDeepUnref (i.e., replace the direct cloneDeepUnref(filters as MaybeRefDeep<...>) and cloneDeepUnref(options as MaybeRefDeep<...>) flows with toValueDeep(...) followed by cloneDeepUnref(...) so root-level getter functions are invoked before cloning). In `@packages/vue-query/src/queryOptions.ts`: - Around line 25-27: The mapped type for QueryOptions incorrectly forces the 'enabled' property to be a getter only; change the mapping for Property extends 'enabled' in QueryOptions so it accepts the core library's Enabled type (boolean | (query)=>boolean) rather than only a no-arg function. Locate the mapped type in QueryOptions (the clause currently returning "() => Enabled<...>") and replace it with the correct Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>> type (or a union of boolean and the predicate signature) so that plain true/false and predicate functions are both accepted; ensure QueryObserverOptions usage remains unchanged. In `@packages/vue-query/src/utils.ts`: - Around line 113-114: toValueDeep currently returns source() directly when source is a function, skipping deep unref/clone normalization and causing inconsistent behavior; modify toValueDeep so it always passes the resolved value through cloneDeepUnref (e.g., compute const resolved = isFunction(source) ? source() : source and return cloneDeepUnref(resolved)) so both function and non-function inputs get identical deep-unref/clone treatment; keep references to toValueDeep, isFunction, cloneDeepUnref and MaybeRefDeep in the change. --- Outside diff comments: In `@packages/vue-query/src/queryClient.ts`: - Around line 304-310: The implementation of fetchQuery doesn't handle getter functions even though an overload accepts (() => FetchQueryOptions<...>); update the implementation signature to accept either a getter or MaybeRefDeep (e.g., options: MaybeRefDeep<FetchQueryOptions<...>> | (() => FetchQueryOptions<...>)) and inside fetchQuery resolve the getter before cloning: detect if options is a function (the getter) and call it to obtain the options, then pass the resolved value to cloneDeepUnref and forward to super.fetchQuery; reference fetchQuery and cloneDeepUnref to locate where to change.🪄 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:
3298b37d-8c6f-49e8-b9b3-09276d25ac36📥 Commits
Reviewing files that changed from the base of the PR and between b97513f2888ed1310a5b39bf91d559c5bc6b83e0 and 47e4c6b93db99593f239cf7d28624e16572f6b0d.
📒 Files selected for processing (9)
.changeset/three-pillows-enter.mdpackages/vue-query/src/__tests__/queryOptions.test-d.tspackages/vue-query/src/__tests__/queryOptions.test.tspackages/vue-query/src/__tests__/useQueries.test-d.tspackages/vue-query/src/index.tspackages/vue-query/src/queryClient.tspackages/vue-query/src/queryOptions.tspackages/vue-query/src/types.tspackages/vue-query/src/utils.ts
@@ -0,0 +1,5 @@1+---2+'@tanstack/vue-query': patch3+---4+5+fix(vue-query): fix type of queryOptions to allow plain properies or getters⚠️ Potential issue | 🟡 Minor
Fix typo in changeset text.
properiesshould bepropertiesin the release note sentence.📝 Proposed edit
-fix(vue-query): fix type of queryOptions to allow plain properies or getters +fix(vue-query): fix type of queryOptions to allow plain properties or getters📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change5-fix(vue-query): fix type of queryOptions to allow plain properies or getters5+fix(vue-query): fix type of queryOptions to allow plain properties or getters🧰 Tools
🪛 LanguageTool
[grammar] ~5-~5: Ensure spelling is correct Context: ...fix type of queryOptions to allow plain properies or getters
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.changeset/three-pillows-enter.md at line 5, Typo in the changeset title string "fix(vue-query): fix type of queryOptions to allow plain properies or getters" — change "properies" to "properties" so the sentence reads "...allow plain properties or getters"; update that exact text in the .changeset entry to correct the spelling.packages/vue-query/src/queryClient.ts line 3OutdatedResolvedby DamianOsipiuk(GitHub profile, opens in a new tab)@@ -1,3 +1,3 @@11 import { nextTick, ref } from 'vue-demi'22 import { QueryClient as QC } from '@tanstack/query-core'3-import { cloneDeepUnref } from './utils'3+import { cloneDeepUnref, toValueDeep } from './utils'⚠️ Potential issue | 🟠 Major
toValueDeepis imported but never used.The function is imported but not utilized anywhere in this file. Based on the PR objective to support getter functions, this appears to be an oversight—getter functions passed to
invalidateQueriesandfetchQueryneed to be resolved before being passed tocloneDeepUnref.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/queryClient.ts` at line 3, The file imports toValueDeep but never uses it; update the call sites where query keys or args are processed (notably in functions/methods named invalidateQueries and fetchQuery) to resolve getter functions before deep-unwrapping by passing inputs through toValueDeep and then into cloneDeepUnref (e.g., replace direct cloneDeepUnref(someInput) with cloneDeepUnref(toValueDeep(someInput))). This ensures getter-based keys/params are evaluated prior to cloning and keeps the existing import usage.packages/vue-query/src/queryClient.ts lines 205 to 209OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -202,6 +202,8 @@202202 TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>,203203 TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>,204204 >(205- filters?: InvalidateQueryFilters<TTaggedQueryKey>,205+ filters?:206+ | InvalidateQueryFilters<TTaggedQueryKey>207+ | (() => InvalidateQueryFilters<TTaggedQueryKey>),206208 options?: MaybeRefDeep<InvalidateOptions>,207209 ): Promise<void>⚠️ Potential issue | 🟡 Minor
Public overload missing getter support for
optionsparameter.The implementation signature (line 214) accepts
(() => InvalidateOptions)for theoptionsparameter, but the public overload only exposesMaybeRefDeep<InvalidateOptions>. If getter support foroptionsis intended, the overload should be updated to match.✏️ Proposed fix to expose getter support in overload
invalidateQueries< TQueryFnData = unknown, TError = DefaultError, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>, TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>, >( filters?: | InvalidateQueryFilters<TTaggedQueryKey> | (() => InvalidateQueryFilters<TTaggedQueryKey>), - options?: MaybeRefDeep<InvalidateOptions>, + options?: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions), ): Promise<void>📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change205- filters?:206- | InvalidateQueryFilters<TTaggedQueryKey>207- | (() => InvalidateQueryFilters<TTaggedQueryKey>),208- options?: MaybeRefDeep<InvalidateOptions>,209- ): Promise<void>205+ filters?:206+ | InvalidateQueryFilters<TTaggedQueryKey>207+ | (() => InvalidateQueryFilters<TTaggedQueryKey>),208+ options?: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions),209+ ): Promise<void>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/queryClient.ts` around lines 205 - 209, The public overload for invalidateQueries in queryClient.ts is missing getter support for the options parameter; update the overload’s options type to include a getter by changing options?: MaybeRefDeep<InvalidateOptions> to options?: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions) (or (() => MaybeRefDeep<InvalidateOptions>) to match your ref handling) so the public signature matches the implementation that accepts (() => InvalidateOptions); adjust the overload for invalidateQueries and ensure references to InvalidateOptions and MaybeRefDeep remain consistent.✅ Addressed in commit 0649ccb
@@ -206,8 +205,17 @@205+ filters?:206+ | InvalidateQueryFilters<TTaggedQueryKey>207+ | (() => InvalidateQueryFilters<TTaggedQueryKey>),206208 options?: MaybeRefDeep<InvalidateOptions>,207209 ): Promise<void>208210 invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(209- filters: MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>> = {},210- options: MaybeRefDeep<InvalidateOptions> = {},211+ filters:212+ | MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>213+ | (() => InvalidateQueryFilters<TTaggedQueryKey>) = {},214+ options: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions) = {},211215 ): Promise<void> {212- const filtersCloned = cloneDeepUnref(filters)213- const optionsCloned = cloneDeepUnref(options)216+ const filtersCloned = cloneDeepUnref(217+ filters as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>,218+ )219+ const optionsCloned = cloneDeepUnref(220+ options as MaybeRefDeep<InvalidateOptions>,221+ )⚠️ Potential issue | 🔴 Critical
Getter functions passed as arguments will not be invoked.
When a getter function
() => InvalidateQueryFiltersis passed, the current implementation casts it toMaybeRefDeep<T>and passes it directly tocloneDeepUnref. However,cloneDeepUnrefwith default parameters (unrefGetters=false) does not invoke root-level getter functions—it only handles nested getters forqueryKeyat level 1.This means the function object itself (not its return value) will be passed to
query-core, causing silent runtime failures.The getter should be resolved first using
toValueDeepbefore cloning:🐛 Proposed fix to resolve getters before cloning
- const filtersCloned = cloneDeepUnref( - filters as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>, - ) - const optionsCloned = cloneDeepUnref( - options as MaybeRefDeep<InvalidateOptions>, - ) + const filtersCloned = cloneDeepUnref( + toValueDeep(filters) as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>, + ) + const optionsCloned = cloneDeepUnref( + toValueDeep(options) as MaybeRefDeep<InvalidateOptions>, + )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/queryClient.ts` around lines 216 - 221, The code currently passes potential getter functions directly into cloneDeepUnref (e.g., when building filtersCloned and optionsCloned), but cloneDeepUnref(unrefGetters=false) won't invoke root-level getters so function objects slip through; fix by first resolving any getters with toValueDeep on the original inputs (filters and options) and then pass the resolved values into cloneDeepUnref (i.e., replace the direct cloneDeepUnref(filters as MaybeRefDeep<...>) and cloneDeepUnref(options as MaybeRefDeep<...>) flows with toValueDeep(...) followed by cloneDeepUnref(...) so root-level getter functions are invoked before cloning).@@ -5,0 +7,21 @@7+ NonUndefinedGuard,8+ QueryKey,9+ QueryObserverOptions,10+} from '@tanstack/query-core'11+12+export type QueryOptions<13+ TQueryFnData = unknown,14+ TError = DefaultError,15+ TData = TQueryFnData,16+ TQueryData = TQueryFnData,17+ TQueryKey extends QueryKey = QueryKey,18+> = {19+ [Property in keyof QueryObserverOptions<20+ TQueryFnData,21+ TError,22+ TData,23+ TQueryData,24+ TQueryKey25+ >]: Property extends 'enabled'26+ ? () => Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>>27+ : QueryObserverOptions<⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "1) Inspect Enabled/QueryObserverOptions definitions in query-core" rg -n --type=ts -C3 'export type Enabled|enabled\??:' packages/query-core echo echo "2) Inspect vue-query QueryOptions enabled mapping" rg -n --type=ts -C3 "Property extends 'enabled'" packages/vue-query/src/queryOptions.ts echo echo "3) Find boolean-enabled queryOptions call patterns in vue-query tests" rg -n --type=ts -C2 'enabled:\s*(true|false)' packages/vue-query/src/__tests__Repository: TanStack/query
Length of output: 22769
🏁 Script executed:
# Get the full Enabled type definition from query-core sed -n '113,125p' packages/query-core/src/types.ts echo "---" # Check the full QueryOptions field definition in query-core sed -n '326,330p' packages/query-core/src/types.ts echo "---" # View the full QueryOptions mapped type in vue-query to understand the structure sed -n '12,40p' packages/vue-query/src/queryOptions.tsRepository: TanStack/query
Length of output: 1291
enabledis now getter-only; plainenabledvalues are no longer accepted.The
QueryOptionsmapped type restrictsenabledto() => Enabled<...>(function-only), but the core library'sEnabledtype is defined asboolean | ((query) => boolean). This breaks existing code usingenabled: trueorenabled: false.Proposed type fix
>]: Property extends 'enabled' - ? () => Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>> + ? + | Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>> + | (() => Enabled< + TQueryFnData, + TError, + TQueryData, + DeepUnwrapRef<TQueryKey> + >) : QueryObserverOptions<🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/queryOptions.ts` around lines 25 - 27, The mapped type for QueryOptions incorrectly forces the 'enabled' property to be a getter only; change the mapping for Property extends 'enabled' in QueryOptions so it accepts the core library's Enabled type (boolean | (query)=>boolean) rather than only a no-arg function. Locate the mapped type in QueryOptions (the clause currently returning "() => Enabled<...>") and replace it with the correct Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>> type (or a union of boolean and the predicate signature) so that plain true/false and predicate functions are both accepted; ensure QueryObserverOptions usage remains unchanged.@@ -109,3 +109,6 @@109109 function isFunction(value: unknown): value is Function {110110 return typeof value === 'function'111111 }112+113+export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {114+ return isFunction(source) ? source() : cloneDeepUnref(source)⚠️ Potential issue | 🟠 Major
Getter branch skips deep unref/clone normalization.
When
sourceis a function,toValueDeepreturnssource()directly, so nested refs/getters are not normalized like they are for non-function input. This can produce different runtime behavior for equivalent inputs.💡 Proposed fix
export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T { - return isFunction(source) ? source() : cloneDeepUnref(source) + const value = isFunction(source) ? source() : source + return cloneDeepUnref(value as MaybeRefDeep<T>) }📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change113-export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {114- return isFunction(source) ? source() : cloneDeepUnref(source)113+export function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {114+ const value = isFunction(source) ? source() : source115+ return cloneDeepUnref(value as MaybeRefDeep<T>)116+}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/utils.ts` around lines 113 - 114, toValueDeep currently returns source() directly when source is a function, skipping deep unref/clone normalization and causing inconsistent behavior; modify toValueDeep so it always passes the resolved value through cloneDeepUnref (e.g., compute const resolved = isFunction(source) ? source() : source and return cloneDeepUnref(resolved)) so both function and non-function inputs get identical deep-unref/clone treatment; keep references to toValueDeep, isFunction, cloneDeepUnref and MaybeRefDeep in the change.More templates
- @tanstack/query-example-angular-auto-refetching
- @tanstack/query-example-angular-basic
- @tanstack/query-example-angular-basic-persister
- @tanstack/query-example-angular-devtools-panel
- @tanstack/query-example-angular-infinite-query-with-max-pages
- @tanstack/query-example-angular-optimistic-updates
- @tanstack/query-example-angular-pagination
- @tanstack/query-example-angular-query-options-from-a-service
- @tanstack/query-example-angular-router
- @tanstack/query-example-angular-rxjs
- @tanstack/query-example-angular-simple
- @tanstack/query-example-preact-simple
- @tanstack/query-example-react-algolia
- @tanstack/query-example-react-auto-refetching
- @tanstack/query-example-react-basic
- @tanstack/query-example-react-basic-graphql-request
- @tanstack/query-example-chat
- @tanstack/query-example-react-default-query-function
- @tanstack/query-example-react-devtools-panel
- @tanstack/query-example-eslint-legacy
- @tanstack/query-example-eslint-plugin-demo
- @tanstack/query-example-react-infinite-query-with-max-pages
- @tanstack/query-example-react-load-more-infinite-scroll
- @tanstack/query-example-react-nextjs
- @tanstack/query-example-react-nextjs-app-prefetching
- @tanstack/query-example-nextjs-suspense-streaming
- @tanstack/query-example-react-offline
- @tanstack/query-example-react-optimistic-updates-cache
- @tanstack/query-example-react-optimistic-updates-ui
- @tanstack/query-example-react-pagination
- @tanstack/query-example-react-playground
- @tanstack/query-example-react-prefetching
- @tanstack/query-example-react-react-native
- @tanstack/query-example-react-router
- @tanstack/query-example-react-rick-morty
- @tanstack/query-example-react-shadow-dom
- @tanstack/query-example-react-simple
- @tanstack/query-example-react-star-wars
- @tanstack/query-example-react-suspense
- @tanstack/query-example-solid-astro
- @tanstack/query-example-solid-basic
- @tanstack/query-example-solid-basic-graphql-request
- @tanstack/query-example-solid-default-query-function
- @tanstack/query-example-solid-offline
- @tanstack/query-example-solid-simple
- @tanstack/query-example-solid-start-streaming
- @tanstack/query-example-svelte-auto-refetching
- @tanstack/query-example-svelte-basic
- @tanstack/query-example-svelte-load-more-infinite-scroll
- @tanstack/query-example-svelte-optimistic-updates
- @tanstack/query-example-svelte-playground
- @tanstack/query-example-svelte-simple
- @tanstack/query-example-svelte-ssr
- @tanstack/query-example-svelte-star-wars
- @tanstack/query-example-vue-2.6-basic
- @tanstack/query-example-vue-2.7-basic
- @tanstack/query-example-vue-basic
- @tanstack/query-example-vue-dependent-queries
- @tanstack/query-example-vue-nuxt3
- @tanstack/query-example-vue-persister
- @tanstack/query-example-vue-simple
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10452@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10452@tanstack/preact-query
npm i https://pkg.pr.new/@tanstack/preact-query@10452@tanstack/preact-query-devtools
npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10452@tanstack/preact-query-persist-client
npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10452@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10452@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10452@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@10452@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@10452@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10452@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10452@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@10452@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@10452@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10452@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10452@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@10452@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10452@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10452@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@10452@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10452@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10452@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@10452@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10452commit:
0649ccbsize-limit report 📦#
Path Size react full 11.99 KB (0%) react minimal 9.02 KB (0%) Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/vue-query/src/queryClient.ts (1)
286-310: ⚠️ Potential issue | 🔴 CriticalfetchQueryoverload accepts getter but implementation doesn't invoke it.The public overload accepts
(() => FetchQueryOptions<...>), but the implementation only acceptsMaybeRefDeep<FetchQueryOptions<...>>. When a getter function is passed,cloneDeepUnrefwill not invoke it—the function object itself gets passed tosuper.fetchQuery(), causing a runtime error.Replace
cloneDeepUnref(options)withtoValueDeep(options)to properly handle both getter functions and reactive references. ThetoValueDeeputility already handles this pattern correctly by checkingisFunction(source)first before falling back tocloneDeepUnref.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/queryClient.ts` around lines 286 - 310, The fetchQuery implementation currently passes cloneDeepUnref(options) to super.fetchQuery which doesn't invoke getter overloads; change the call in the fetchQuery method to use toValueDeep(options) so functions (getter overloads) and refs are resolved before forwarding to super.fetchQuery; ensure you update any imports to include toValueDeep and keep the existing overload signatures (MaybeRefDeep and FetchQueryOptions) unchanged.🧹 Nitpick comments (1)
packages/vue-query/src/index.ts (1)
8-9: Consider combining exports from./queryOptions.Both the runtime
queryOptionsfunction and theQueryOptionstype are exported from the same module. These can be combined into a single export statement.♻️ Optional consolidation
-export { queryOptions } from './queryOptions' -export { type QueryOptions } from './queryOptions' +export { queryOptions, type QueryOptions } from './queryOptions'🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/index.ts` around lines 8 - 9, The exports in index.ts export both the runtime symbol queryOptions and the type QueryOptions separately; combine them into a single consolidated export from './queryOptions' by exporting queryOptions and type QueryOptions together (reference symbols: queryOptions, QueryOptions, and module './queryOptions') so the file uses one export statement instead of two.🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Outside diff comments: In `@packages/vue-query/src/queryClient.ts`: - Around line 286-310: The fetchQuery implementation currently passes cloneDeepUnref(options) to super.fetchQuery which doesn't invoke getter overloads; change the call in the fetchQuery method to use toValueDeep(options) so functions (getter overloads) and refs are resolved before forwarding to super.fetchQuery; ensure you update any imports to include toValueDeep and keep the existing overload signatures (MaybeRefDeep and FetchQueryOptions) unchanged. --- Nitpick comments: In `@packages/vue-query/src/index.ts`: - Around line 8-9: The exports in index.ts export both the runtime symbol queryOptions and the type QueryOptions separately; combine them into a single consolidated export from './queryOptions' by exporting queryOptions and type QueryOptions together (reference symbols: queryOptions, QueryOptions, and module './queryOptions') so the file uses one export statement instead of two.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
61d62eb3-86e6-47db-9747-92d7e1d567e7📥 Commits
Reviewing files that changed from the base of the PR and between 47e4c6b93db99593f239cf7d28624e16572f6b0d and 0649ccb030238f990ada9274cba6706dc0716efa.
📒 Files selected for processing (9)
.changeset/three-pillows-enter.mdpackages/vue-query/src/__tests__/queryOptions.test-d.tspackages/vue-query/src/__tests__/queryOptions.test.tspackages/vue-query/src/__tests__/useQueries.test-d.tspackages/vue-query/src/index.tspackages/vue-query/src/queryClient.tspackages/vue-query/src/queryOptions.tspackages/vue-query/src/types.tspackages/vue-query/src/utils.ts
✅ Files skipped from review due to trivial changes (3)
- packages/vue-query/src/tests/queryOptions.test.ts
- packages/vue-query/src/types.ts
- packages/vue-query/src/tests/useQueries.test-d.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/vue-query/src/utils.ts
- packages/vue-query/src/tests/queryOptions.test-d.ts
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Adds getter/thunk support across vue-query: new
QueryOptionstypes andMaybeGetter, atoValueDeeputility,queryOptionsoverloads accepting thunks,QueryClientoverloads accepting thunks for filters/options, an index type re-export, type-test updates, and a changeset entry.Changes#
.changeset/three-pillows-enter.mdqueryOptions.packages/vue-query/src/index.tsQueryOptionstype fromqueryOptionsto expose the new type-level API.packages/vue-query/src/types.tspackages/vue-query/src/queryOptions.tsQueryOptions,DefinedInitialQueryOptions,UndefinedInitialQueryOptions; added overloads forqueryOptionsaccepting thunks returning those types (returns typed thunk withqueryKey: DataTag<...>).packages/vue-query/src/utils.tspackages/vue-query/src/queryClient.tsinvalidateQueriesandfetchQueryaccept filters/options asMaybeRefDeep<...>or zero-arg factories() => ...; implementation casts factory inputs and delegates normalization (via deep-unref/clone) before scheduling refetches.packages/vue-query/src/__tests__/queryOptions.test-d.ts,packages/vue-query/src/__tests__/useQueries.test-d.ts@ts-expect-errorplacement, added getter-basedqueryOptionsscenarios, and new assertions verifyingqueryFn/queryKey/staleTimeaccess anduseQueriesdata inference for plain andselect-mapped results.packages/vue-query/src/__tests__/queryOptions.test.tsQueryOptions, capturedqueryOptions(object)inoptionsvariable, and asserted referential equality (toBe) is preserved.Sequence Diagram#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Poem#
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)#
✅ Passed checks (1 passed)
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
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