Skip to content
Source
Sign inSign up
TanStack/query

fix(vue-query): fix type of queryOptions to allow plain properies or getters #10452

MergedDamianOsipiuk(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/10452/headmerged 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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      📝 Walkthrough

      Walkthrough

      Adds getter/thunk support across vue-query: new QueryOptions types and MaybeGetter, a toValueDeep utility, queryOptions overloads accepting thunks, QueryClient overloads accepting thunks for filters/options, an index type re-export, type-test updates, and a changeset entry.

      Changes

      Cohort / File(s)Summary
      Changeset
      .changeset/three-pillows-enter.md
      New changeset entry documenting the patch release for getter/thunk support in queryOptions.
      Public API / Exports
      packages/vue-query/src/index.ts
      Re-exported the QueryOptions type from queryOptions to expose the new type-level API.
      Type Utilities
      packages/vue-query/src/types.ts
      Added `export type MaybeGetter = T
      Core Types & Overloads
      packages/vue-query/src/queryOptions.ts
      Introduced exported QueryOptions, DefinedInitialQueryOptions, UndefinedInitialQueryOptions; added overloads for queryOptions accepting thunks returning those types (returns typed thunk with queryKey: DataTag<...>).
      Runtime Utilities
      packages/vue-query/src/utils.ts
      Added `toValueDeep(source: (() => T)
      QueryClient behavior
      packages/vue-query/src/queryClient.ts
      Updated overloads/signatures so invalidateQueries and fetchQuery accept filters/options as MaybeRefDeep<...> or zero-arg factories () => ...; implementation casts factory inputs and delegates normalization (via deep-unref/clone) before scheduling refetches.
      Type-level tests
      packages/vue-query/src/__tests__/queryOptions.test-d.ts, packages/vue-query/src/__tests__/useQueries.test-d.ts
      Adjusted/tested TypeScript inference: moved @ts-expect-error placement, added getter-based queryOptions scenarios, and new assertions verifying queryFn/queryKey/staleTime access and useQueries data inference for plain and select-mapped results.
      Runtime tests
      packages/vue-query/src/__tests__/queryOptions.test.ts
      Switched input type to QueryOptions, captured queryOptions(object) in options variable, and asserted referential equality (toBe) is preserved.

      Sequence Diagram

      sequenceDiagram
          participant User
          participant queryOptions
          participant QueryClient
          participant toValueDeep
          participant Core
      
          User->>queryOptions: provide plain object or zero-arg getter
          alt Getter path
              queryOptions->>queryOptions: accept/return thunk overload
              queryOptions-->>User: thunk that yields options
              User->>QueryClient: call invalidateQueries/fetchQuery with thunk
          else Plain value path
              queryOptions->>queryOptions: accept direct overload
              User->>QueryClient: call invalidateQueries/fetchQuery with value
          end
      
          QueryClient->>toValueDeep: normalize filters/options (invoke if function)
          toValueDeep-->>QueryClient: normalized plain value
          QueryClient->>Core: forward normalized filters/options to core API
          Core-->>QueryClient: result/ack
          QueryClient-->>User: update/refetch behavior

      Estimated code review effort

      🎯 4 (Complex) | ⏱️ ~45 minutes

      Poem

      🐰 I nibble types and chew on thunks with glee, Options now hop free—from getters they flee. Deep-unwrapped carrots and cloned-value delight, QueryClient hums through the soft moonlight. ✨

      🚥 Pre-merge checks | ✅ 1 | ❌ 2

      ❌ Failed checks (1 warning, 1 inconclusive)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      Description check❓ InconclusiveThe PR description lacks substantive implementation details in the Changes section, containing only a placeholder comment and unchecked checklists.Add a detailed explanation of what was changed (e.g., type modifications to queryOptions), why these changes fix the issue, and confirm both contributing guide compliance and test execution were completed.
      ✅ Passed checks (1 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title accurately describes the main change: fixing the type of queryOptions in vue-query to allow plain properties or getters, which aligns with the substantial type updates across multiple files.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `do/fix-query-options-types`

      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 and usage tips.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 0649ccb030238f990ada9274cba6706dc0716efa

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded1m 21sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded<1sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-04-11 15:53:44 UTC

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

      🚀 Changeset Version Preview

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

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/vue-query5.97.0 → 5.98.0Changeset
      @tanstack/angular-query-experimental5.97.0 → 5.98.0Dependent
      @tanstack/angular-query-persist-client5.97.0 → 5.98.0Dependent
      @tanstack/eslint-plugin-query5.97.0 → 5.98.0Dependent
      @tanstack/preact-query5.97.0 → 5.98.0Dependent
      @tanstack/preact-query-devtools5.97.0 → 5.98.0Dependent
      @tanstack/preact-query-persist-client5.97.0 → 5.98.0Dependent
      @tanstack/query-async-storage-persister5.97.0 → 5.98.0Dependent
      @tanstack/query-broadcast-client-experimental5.97.0 → 5.98.0Dependent
      @tanstack/query-core5.97.0 → 5.98.0Dependent
      @tanstack/query-devtools5.97.0 → 5.98.0Dependent
      @tanstack/query-persist-client-core5.97.0 → 5.98.0Dependent
      @tanstack/query-sync-storage-persister5.97.0 → 5.98.0Dependent
      @tanstack/react-query5.97.0 → 5.98.0Dependent
      @tanstack/react-query-devtools5.97.0 → 5.98.0Dependent
      @tanstack/react-query-next-experimental5.97.0 → 5.98.0Dependent
      @tanstack/react-query-persist-client5.97.0 → 5.98.0Dependent
      @tanstack/solid-query5.97.0 → 5.98.0Dependent
      @tanstack/solid-query-devtools5.97.0 → 5.98.0Dependent
      @tanstack/solid-query-persist-client5.97.0 → 5.98.0Dependent

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/vue-query-devtools6.1.14 → 6.1.15Changeset
      @tanstack/svelte-query6.1.14 → 6.1.15Dependent
      @tanstack/svelte-query-devtools6.1.14 → 6.1.15Dependent
      @tanstack/svelte-query-persist-client6.1.14 → 6.1.15Dependent
    5. 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 | 🔴 Critical

      Implementation signature and body don't handle getter functions.

      The overload (lines 286-296) accepts (() => FetchQueryOptions<...>), but the implementation signature (lines 305-307) only declares MaybeRefDeep<FetchQueryOptions<...>>. When a getter is passed, it will be mishandled by cloneDeepUnref the same way as in invalidateQueries.

      🐛 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.md
      • packages/vue-query/src/__tests__/queryOptions.test-d.ts
      • packages/vue-query/src/__tests__/queryOptions.test.ts
      • packages/vue-query/src/__tests__/useQueries.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/types.ts
      • packages/vue-query/src/utils.ts
      @@ -0,0 +1,5 @@
      1+---
      2+'@tanstack/vue-query': patch
      3+---
      4+
      5+fix(vue-query): fix type of queryOptions to allow plain properies or getters
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      ⚠️ Potential issue | 🟡 Minor

      Fix typo in changeset text.

      properies should be properties in 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 change
      5-fix(vue-query): fix type of queryOptions to allow plain properies or getters
      5+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.
      @@ -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+ )
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      ⚠️ Potential issue | 🔴 Critical

      Getter functions passed as arguments will not be invoked.

      When a getter function () => InvalidateQueryFilters is passed, the current implementation casts it to MaybeRefDeep<T> and passes it directly to cloneDeepUnref. However, cloneDeepUnref with default parameters (unrefGetters=false) does not invoke root-level getter functions—it only handles nested getters for queryKey at 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 toValueDeep before 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+ TQueryKey
      25+ >]: Property extends 'enabled'
      26+ ? () => Enabled<TQueryFnData, TError, TQueryData, DeepUnwrapRef<TQueryKey>>
      27+ : QueryObserverOptions<
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      ⚠️ 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.ts

      Repository: TanStack/query

      Length of output: 1291


      enabled is now getter-only; plain enabled values are no longer accepted.

      The QueryOptions mapped type restricts enabled to () => Enabled<...> (function-only), but the core library's Enabled type is defined as boolean | ((query) => boolean). This breaks existing code using enabled: true or enabled: 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)
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      ⚠️ Potential issue | 🟠 Major

      Getter branch skips deep unref/clone normalization.

      When source is a function, toValueDeep returns source() 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 change
      113-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() : source
      115+ 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.
    6. More templates

      @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@10452

      commit: 0649ccb

    7. size-limit report 📦

      PathSize
      react full11.99 KB (0%)
      react minimal9.02 KB (0%)
    8. 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 | 🔴 Critical

      fetchQuery overload accepts getter but implementation doesn't invoke it.

      The public overload accepts (() => FetchQueryOptions<...>), but the implementation only accepts MaybeRefDeep<FetchQueryOptions<...>>. When a getter function is passed, cloneDeepUnref will not invoke it—the function object itself gets passed to super.fetchQuery(), causing a runtime error.

      Replace cloneDeepUnref(options) with toValueDeep(options) to properly handle both getter functions and reactive references. The toValueDeep utility already handles this pattern correctly by checking isFunction(source) first before falling back to cloneDeepUnref.

      🤖 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 queryOptions function and the QueryOptions type 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.md
      • packages/vue-query/src/__tests__/queryOptions.test-d.ts
      • packages/vue-query/src/__tests__/queryOptions.test.ts
      • packages/vue-query/src/__tests__/useQueries.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/types.ts
      • packages/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.