Skip to content
Source
Sign inSign up
TanStack/query

[WIP] Angular injectQueries fixes #8690

Mergedcrutchcorn(GitHub profile, opens in a new tab)merged 15 commits intomain fromrefs/pull/8690/headmerged by arnoud-dv(GitHub profile, opens in a new tab) View on GitHub

This PR:

  • Fixes the types of injectQueries
  • Add type tests for injectQueries
  • Adds initial tests for injectQueries runtime
  • Fixes runtime behavior of injectQueries

TODO:

  • Figure out where to add signalProxy

Summary by CodeRabbit

  • New Features
    • Updated multi-query injection API to accept function-based options and return a reactive signal, enabling more flexible and responsive configuration.
    • Improved per-query result typing for clearer, more accurate type inference.
  • Tests
    • Added integration tests validating asynchronous multi-query behavior and state updates.
    • Added type-level tests to ensure correct inference across various usage patterns.
  • Chores
    • Upgraded Angular testing library to v18 for improved tooling and compatibility in development.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: angular-query-experimental

    2. View your CI Pipeline Execution ↗ for commit 26d7f36575dcc568a2c110d7b4497361a8f270f6

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

      ☁️ Nx Cloud last updated this comment at 2025-09-18 17:42:21 UTC

    3. More templates

      @tanstack/angular-query-experimental

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

      @tanstack/eslint-plugin-query

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

      @tanstack/query-async-storage-persister

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

      @tanstack/query-broadcast-client-experimental

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

      @tanstack/query-core

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

      @tanstack/query-devtools

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

      @tanstack/query-persist-client-core

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

      @tanstack/query-sync-storage-persister

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

      @tanstack/react-query

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

      @tanstack/react-query-devtools

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

      @tanstack/react-query-next-experimental

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

      @tanstack/react-query-persist-client

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

      @tanstack/solid-query

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

      @tanstack/solid-query-devtools

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

      @tanstack/solid-query-persist-client

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

      @tanstack/svelte-query

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

      @tanstack/svelte-query-devtools

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

      @tanstack/svelte-query-persist-client

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

      @tanstack/vue-query

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

      @tanstack/vue-query-devtools

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

      commit: 26d7f36

    4. Sizes for commit 26d7f36575dcc568a2c110d7b4497361a8f270f6:

      BranchBundle Size
      Main
      This PR
    5. Hey @crutchcorn! I just noticed you dropped a PR to fix injectQueries. I've been using a custom build of @tanstack/angular-query-experimental from this PR (https://github.com/TanStack/query/pull/8007) that has been working great for me in production, as I really needed injectQueries for my application.

      I'm not sure if that MR can serve as an inspiration for your work, or possibly even avoid work altogether?

    6. Should be something like this to proxify the individual queries, but I'm getting errors. I will look into this more.

          const resultSignal = computed(() => {
            const subscriberResult = resultFromSubscriberSignal()
            const optimisticResult = optimisticCombinedResultSignal()
            return subscriberResult ?? optimisticResult
          })
      
          return computed(() => {
            const result = resultSignal()
            if (Array.isArray(result)) {
              return result.map((query) => signalProxy(query))
            }
            return result
          })
      
        }) as unknown as Signal<TCombinedResult>
    7. More todos:

      • Should be able to throw an error when throwOnError is true
      • Using map on result gives error TS2339: Property map does not exist on type TCombinedResult.
      • The computed with proxified queries needs to be improved so that new signals are not created for each query when the result changes.
      • Align signature with other functions: parameters injectQueriesFn and options
      • Persistence
    8. @arnoud-dv @crutchcorn Are you still working on the feature? Do you need some help?

    9. Yes, help with injectQueries is welcome Thomas. I don't have enough time at the moment.

    10. Walkthrough

      Refactors injectQueries to accept a function-based options provider and updates public types (InjectQueriesOptions, QueriesOptions, QueriesResults). Implements reactive observer wiring with signals and signalProxy. Adds unit and d.ts tests for new typing and behavior. Updates Angular testing library dev dependency versions in two packages.

      Changes

      Cohort / File(s)Summary of changes
      Dev testing deps
      packages/angular-query-experimental/package.json, packages/angular-query-persist-client/package.json
      Add/upgrade dev dependency @testing-library/angular to ^18.0.0.
      API and reactive flow refactor
      packages/angular-query-experimental/src/inject-queries.ts
      Change injectQueries signature to accept optionsFn: () => InjectQueriesOptions; add/export InjectQueriesOptions; revise QueriesOptions and QueriesResults typing to per-query mapping; rework runtime to derive options, observer, and results via signals and signalProxy.
      Type-level tests
      packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts
      New d.ts tests validating TData inference, overloads, skipToken handling, and dynamic query result typing for injectQueries.
      Runtime tests
      packages/angular-query-experimental/src/__tests__/inject-queries.test.ts
      New integration test verifying two async queries sequence and signal-driven state progression using Angular Testing Library and QueryClient.

      Sequence Diagram(s)

      sequenceDiagram
        autonumber
        actor C as Component
        participant IQ as injectQueries
        participant OF as optionsFn()
        participant QC as QueryClient
        participant OBS as observerSignal
        participant RS as resultSignal
      
        C->>IQ: call with optionsFn, injector?
        IQ->>OF: compute options (queries, combine)
        IQ->>QC: apply defaultQueryOptions
        IQ->>OBS: create reactive QueriesObserver
        OBS-->>IQ: optimistic results (signal)
        OBS-->>IQ: subscribe for updates (untracked)
        IQ->>RS: merge subscriber/optimistic results
        RS-->>C: Signal<TCombinedResult> (proxied per-query)
      
        note over IQ,OBS: Each query result wrapped via signalProxy

      Estimated code review effort

      🎯 4 (Complex) | ⏱️ ~60 minutes

      • TanStack/query#8703 — Tracks the injectQueries refactor and API/type changes implemented here.
      • TanStack/query#9655 — Touches the same injectQueries API surface, relocating/exporting it under experimental paths.
      • TanStack/query#9270 — Modifies injectQueries signature, types, and associated tests/docs, overlapping with this refactor.

      Poem

      A rabbit twitched its whiskered nose, New signals hum where options rose; Queries hop in tidy lines, Types align like perfect pines; Tests burrow deep to check the trace— Then pop! two carrots, data in place. 🥕🐇

      Pre-merge checks and finishing touches

      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title Check✅ PassedThe title "[WIP] Angular injectQueries fixes" directly reflects the primary change set (fixes to injectQueries in the Angular package) and is concise and relevant for reviewers; the only drawback is the "[WIP]" prefix which is extraneous for a merge-ready title.
      Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
      ✨ Finishing touches
      • 📝 Generate Docstrings
        🧪 Generate unit tests
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      • Commit unit tests in branch `angular-inject-queries-fixes`

      📜 Recent review details

      Configuration used: CodeRabbit UI

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 3f5156db7e6c6cb7eb6b3a7033498b402d80cde7 and 26d7f36575dcc568a2c110d7b4497361a8f270f6.

      📒 Files selected for processing (1)
      • packages/angular-query-experimental/src/__tests__/inject-queries.test.ts (1 hunks)
      🚧 Files skipped from review as they are similar to previous changes (1)
      • packages/angular-query-experimental/src/tests/inject-queries.test.ts
      ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
      • GitHub Check: Preview
      • GitHub Check: Test

      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.
    11. Actionable comments posted: 5

      🧹 Nitpick comments (5)
      packages/angular-query-experimental/src/__tests__/test-utils.ts (2)

      50-53: Prefer safe hasOwnProperty.

      Use Object.prototype.hasOwnProperty.call to avoid prototype pitfalls.

      -  return (
      -    component.hasOwnProperty(property) && (component as any)[property][SIGNAL]
      -  )
      +  return (
      +    Object.prototype.hasOwnProperty.call(component, property) &&
      +    (component as any)[property][SIGNAL]
      +  )

      59-68: Forward-compat risk: using @angular/core/primitives/signals.

      These are private internals and may change across Angular minors. Keep an eye on Angular 20.x release notes; if instability shows up, consider an adapter or gated usage in tests only.

      packages/angular-query-experimental/src/inject-queries.ts (2)

      259-269: Ensure observer is destroyed on component destroy (no listeners path).

      If we never subscribe (e.g., during restore), the instance isn’t destroyed. Register destroy hook.

           const observerSignal = (() => {
             let instance: QueriesObserver<TCombinedResult> | null = null
      
             return computed(() => {
               return (instance ||= new QueriesObserver<TCombinedResult>(
                 queryClient,
                 defaultedQueries(),
                 optionsSignal() as QueriesObserverOptions<TCombinedResult>,
               ))
             })
           })()
      +    destroyRef.onDestroy(() => observerSignal().destroy())

      1-37: Types: skipToken widening looks fine; consider using typeof for tighter inference.

      type SkipTokenForCreateQueries = symbol works, but typeof skipToken would preserve the unique symbol for stricter discriminants.

      packages/angular-query-experimental/src/__tests__/inject-queries.test.tsx (1)

      68-71: Stabilize snapshot collection to avoid over-collection.

      If options change or additional intermediate states appear, this may push >3 snapshots. Consider guarding pushes with a simple dedupe on JSON.stringify or reading only data fields.

      📜 Review details

      Configuration used: CodeRabbit UI

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 94ee0ebeff9b65c2ad381ea866389f925865113c and 3d4612258bf2430eb269496bfa3e5626e0bc4da3.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (5)
      • packages/angular-query-experimental/package.json (1 hunks)
      • packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts (1 hunks)
      • packages/angular-query-experimental/src/__tests__/inject-queries.test.tsx (1 hunks)
      • packages/angular-query-experimental/src/__tests__/test-utils.ts (1 hunks)
      • packages/angular-query-experimental/src/inject-queries.ts (8 hunks)
      🧰 Additional context used
      🧠 Learnings (1)
      📚 Learning: 2025-09-02T17:57:33.184Z
      Learnt from: TkDodo
      PR: TanStack/query#9612
      File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
      Timestamp: 2025-09-02T17:57:33.184Z
      Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

      Applied to files:

      • packages/angular-query-experimental/package.json
      🧬 Code graph analysis (2)
      packages/angular-query-experimental/src/__tests__/inject-queries.test.tsx (2)
      packages/angular-query-experimental/src/inject-queries.ts (1)
      • injectQueries (223-325)
      packages/angular-query-experimental/src/__tests__/test-utils.ts (1)
      • evaluateSignals (10-29)
      packages/angular-query-experimental/src/inject-queries.ts (3)
      packages/angular-query-experimental/src/types.ts (3)
      • CreateQueryOptions (41-55)
      • CreateQueryResult (126-129)
      • DefinedCreateQueryResult (134-139)
      packages/query-core/src/queriesObserver.ts (4)
      • result (195-210)
      • QueriesObserver (35-286)
      • QueriesObserverOptions (29-33)
      • observer (263-269)
      packages/angular-query-experimental/src/signal-proxy.ts (1)
      • signalProxy (14-46)
      ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
      • GitHub Check: Test
      • GitHub Check: Preview
      🔇 Additional comments (5)
      packages/angular-query-experimental/package.json (1)

      77-77: Dev dep OK; verify Angular 20 compatibility matrix.

      "@testing-library/angular@^18" should work, but please confirm it aligns with Angular 20 and our Node/TS versions used in CI.

      packages/angular-query-experimental/src/inject-queries.ts (1)

      218-229: API note: optionsFn DI usage clarified.

      Nice move to optionsFn. With the ngInjector fix above, inject() within optionsFn will be safe across re-evaluations.

      packages/angular-query-experimental/src/__tests__/inject-queries.test.tsx (1)

      35-45: Test structure LGTM.

      Nicely exercises two concurrent queries and UI rendering with zoneless change detection.

      packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts (2)

      131-145: Type test for conditional skipToken is solid.

      Covers the widened union and expected data(): number | undefined.


      147-176: Great coverage for dynamic mixed queries.

      The branded Signal assertion reduces regressions in result typing.

      @@ -7,7 +7,7 @@
      77 /* eslint jsdoc/require-jsdoc: 0, jsdoc/require-param: 0 */
      88
      99 // Evaluate all signals on an object and return the result
      10-function evaluateSignals<T extends Record<string, any>>(
      10+export function evaluateSignals<T extends Record<string, any>>(
      1111 obj: T,
      1212 ): { [K in keyof T]: ReturnType<T[K]> } {
      1313 const result: Partial<{ [K in keyof T]: ReturnType<T[K]> }> = {}

      🛠️ Refactor suggestion

      Tighten evaluateSignals return type to signal keys only.

      Current return type claims all keys, but only signal properties are evaluated. Narrow it to signal keys to avoid misleading types.

      -export function evaluateSignals<T extends Record<string, any>>(
      -  obj: T,
      -): { [K in keyof T]: ReturnType<T[K]> } {
      +export function evaluateSignals<T extends Record<string, any>>(
      +  obj: T,
      +): {
      +  [K in keyof T as T[K] extends Signal<any> ? K : never]: T[K] extends Signal<
      +    infer R
      +  >
      +    ? R
      +    : never
      +} {
         const result: Partial<{ [K in keyof T]: ReturnType<T[K]> }> = {}
      📝 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.

      export function evaluateSignals<T extends Record<string, any>>(
        obj: T,
      ): {
        [K in keyof T as T[K] extends Signal<any> ? K : never]: T[K] extends Signal<
          infer R
        >
          ? R
          : never
      } {
        const result: Partial<{ [K in keyof T]: ReturnType<T[K]> }> = {}
      🤖 Prompt for AI Agents
      In packages/angular-query-experimental/src/__tests__/test-utils.ts around lines
      10-13, the evaluateSignals return type currently claims all keys of T but only
      evaluates signal properties; change the generic return mapping to include only
      those keys whose values are signals (or functions returning values) using a
      conditional key remap (e.g., K in keyof T as T[K] extends Signal | (() => any) ?
      K : never) and ReturnType<T[K]> for the value type, and update the local
      result/Partial typing to match the narrowed mapped type so the function
      signature accurately reflects that non-signal keys are omitted.
      @@ -223,3 +234,13 @@
      223234 const queryClient = inject(QueryClient)
      224235 const isRestoring = injectIsRestoring()
      225236
      237+ /**
      238+ * Signal that has the default options from query client applied
      239+ * computed() is used so signals can be inserted into the options
      240+ * making it reactive. Wrapping options in a function ensures embedded expressions
      241+ * are preserved and can keep being applied after signal changes
      242+ */
      243+ const optionsSignal = computed(() => {
      244+ return runInInjectionContext(injector ?? ngInjector, () => optionsFn())
      245+ })
      246+

      ⚠️ Potential issue

      Undefined identifier 'ngInjector' breaks DI at runtime.

      ngInjector is not defined. Computed will throw the first time it runs.

         return runInInjectionContext(injector ?? inject(Injector), () => {
           const destroyRef = inject(DestroyRef)
           const ngZone = inject(NgZone)
           const queryClient = inject(QueryClient)
           const isRestoring = injectIsRestoring()
      +    // Capture the active injector for re-use inside computed/Effects
      +    const ngInjector = inject(Injector)
      
           /**
            * Signal that has the default options from query client applied
      @@
      -    const optionsSignal = computed(() => {
      -      return runInInjectionContext(injector ?? ngInjector, () => optionsFn())
      -    })
      +    const optionsSignal = computed(() =>
      +      runInInjectionContext(ngInjector, () => optionsFn()),
      +    )
      📝 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.

          // Capture the active injector for re-use inside computed/Effects
          const ngInjector = inject(Injector)
      
          const optionsSignal = computed(() =>
            runInInjectionContext(ngInjector, () => optionsFn()),
          )
      🤖 Prompt for AI Agents
      In packages/angular-query-experimental/src/inject-queries.ts around lines 243 to
      246, the fallback identifier "ngInjector" is undefined and causes a runtime DI
      error; replace the undefined identifier by calling Angular's inject(Injector)
      directly (e.g. use injector ?? inject(Injector)) and ensure you import both
      inject and Injector from @angular/core at the top of the file so the computed
      callback uses a valid injector at runtime.
      @@ -263,5 +296,17 @@
      263- : ngZone.runOutsideAngular(() =>
      264- observer.subscribe(notifyManager.batchCalls(result.set)),
      265- )
      266- destroyRef.onDestroy(unsubscribe)
      296+ const observer = observerSignal()
      297+ const [_optimisticResult, getCombinedResult] = optimisticResultSignal()
      298+
      299+ untracked(() => {
      300+ const unsubscribe = isRestoring()
      301+ ? () => undefined
      302+ : ngZone.runOutsideAngular(() =>
      303+ observer.subscribe(
      304+ notifyManager.batchCalls((state) => {
      305+ resultFromSubscriberSignal.set(getCombinedResult(state))
      306+ }),
      307+ ),
      308+ )
      309+
      310+ destroyRef.onDestroy(unsubscribe)
      311+ })
      267312 })

      ⚠️ Potential issue

      Subscription leak on options changes; use effect cleanup.

      Each re-run re-subscribes without unsubscribing the previous listener. Use onCleanup to prevent duplicate listeners.

      -    effect(() => {
      +    effect((onCleanup) => {
             const observer = observerSignal()
             const [_optimisticResult, getCombinedResult] = optimisticResultSignal()
      
             untracked(() => {
               const unsubscribe = isRestoring()
                 ? () => undefined
                 : ngZone.runOutsideAngular(() =>
                     observer.subscribe(
                       notifyManager.batchCalls((state) => {
                         resultFromSubscriberSignal.set(getCombinedResult(state))
                       }),
                     ),
                   )
      
               destroyRef.onDestroy(unsubscribe)
      +        onCleanup(unsubscribe)
             })
           })
      📝 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.

          effect((onCleanup) => {
            const observer = observerSignal()
            const [_optimisticResult, getCombinedResult] = optimisticResultSignal()
      
            untracked(() => {
              const unsubscribe = isRestoring()
                ? () => undefined
                : ngZone.runOutsideAngular(() =>
                    observer.subscribe(
                      notifyManager.batchCalls((state) => {
                        resultFromSubscriberSignal.set(getCombinedResult(state))
                      }),
                    ),
                  )
      
              destroyRef.onDestroy(unsubscribe)
              onCleanup(unsubscribe)
            })
          })
      🤖 Prompt for AI Agents
      In packages/angular-query-experimental/src/inject-queries.ts around lines 295 to
      312, the effect re-subscribes on each run without removing the previous
      subscription causing a leak; change the effect to register a cleanup that calls
      the previously created unsubscribe function (e.g., declare unsubscribe in the
      outer scope, assign it inside untracked, and call it from onCleanup/returned
      cleanup) so each re-run unsubscribes the prior listener, and keep
      destroyRef.onDestroy to also call unsubscribe to cover component teardown.
      @@ -267,4 +306,19 @@
      306+ }),
      307+ ),
      308+ )
      309+
      310+ destroyRef.onDestroy(unsubscribe)
      311+ })
      267312 })
      268313
      269- return result
      270- })
      314+ const resultSignal = computed(() => {
      315+ const subscriberResult = resultFromSubscriberSignal()
      316+ const optimisticResult = optimisticCombinedResultSignal()
      317+ return subscriberResult ?? optimisticResult
      318+ })
      319+
      320+ return computed(() => {
      321+ const result = resultSignal()
      322+ return result.map((query) => signalProxy(signal(query)))
      323+ })
      324+ }) as unknown as Signal<TCombinedResult>

      🛠️ Refactor suggestion

      Use computed instead of signal for per-item wrapping.

      signal(query) freezes the reference; updates rely on recreating proxies. Using computed(() => query) lets the proxy track the latest item while still allowing memoization strategies later.

      🤖 Prompt for AI Agents
      In packages/angular-query-experimental/src/inject-queries.ts around lines 320 to
      324, the current per-item wrapper uses signal(query) which freezes the reference
      and forces proxy recreation; replace signal(query) with computed(() => query) so
      the proxy can track the latest item while keeping memoization possibilities.
      Update the mapping to return signalProxy(computed(() => query)) (or equivalent
      helper) for each query, and add/adjust imports for computed if not already
      imported.

      ⚠️ Potential issue

      Do not assume combined result is an array.

      When combine returns a non-array, result.map will throw. Handle arrays and objects.

      -    return computed(() => {
      -      const result = resultSignal()
      -      return result.map((query) => signalProxy(signal(query)))
      -    })
      +    return computed(() => {
      +      const result = resultSignal() as any
      +      if (Array.isArray(result)) {
      +        // Proxify each query result
      +        return result.map((query: any) => signalProxy(computed(() => query)))
      +      }
      +      // Proxify the combined object result
      +      return signalProxy(computed(() => result))
      +    })
      📝 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.

          return computed(() => {
            const result = resultSignal() as any
            if (Array.isArray(result)) {
              // Proxify each query result
              return result.map((query: any) => signalProxy(computed(() => query)))
            }
            // Proxify the combined object result
            return signalProxy(computed(() => result))
          })
        }) as unknown as Signal<TCombinedResult>
    12. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: angular-query-persist-client

    13. Codecov Report

      :x: Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 46.19%. Comparing base (a2151d2) to head (26d7f36). :warning: Report is 2 commits behind head on main.

      Additional details and impacted files

      Impacted file tree graph

      @@            Coverage Diff             @@
      ##             main    #8690      +/-   ##
      ==========================================
      + Coverage   45.77%   46.19%   +0.42%     
      ==========================================
        Files         213      213              
        Lines        8429     8453      +24     
        Branches     1916     1920       +4     
      ==========================================
      + Hits         3858     3905      +47     
      + Misses       4124     4105      -19     
      + Partials      447      443       -4     
      ComponentsCoverage Δ
      @tanstack/angular-query-experimental94.08% <94.44%> (+7.01%):arrow_up:
      @tanstack/eslint-plugin-query83.24% <ø> (ø)
      @tanstack/query-async-storage-persister43.85% <ø> (ø)
      @tanstack/query-broadcast-client-experimental24.39% <ø> (ø)
      @tanstack/query-codemods0.00% <ø> (ø)
      @tanstack/query-core97.48% <ø> (ø)
      @tanstack/query-devtools3.48% <ø> (ø)
      @tanstack/query-persist-client-core79.60% <ø> (ø)
      @tanstack/query-sync-storage-persister84.61% <ø> (ø)
      @tanstack/query-test-utils77.77% <ø> (ø)
      @tanstack/react-query96.00% <ø> (ø)
      @tanstack/react-query-devtools10.00% <ø> (ø)
      @tanstack/react-query-next-experimental∅ <ø> (∅)
      @tanstack/react-query-persist-client100.00% <ø> (ø)
      @tanstack/solid-query78.06% <ø> (ø)
      @tanstack/solid-query-devtools∅ <ø> (∅)
      @tanstack/solid-query-persist-client100.00% <ø> (ø)
      @tanstack/svelte-query87.58% <ø> (ø)
      @tanstack/svelte-query-devtools∅ <ø> (∅)
      @tanstack/svelte-query-persist-client100.00% <ø> (ø)
      @tanstack/vue-query71.10% <ø> (ø)
      @tanstack/vue-query-devtools∅ <ø> (∅)
      :rocket: New features to boost your workflow:
      • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
      • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
  • Actionable comments posted: 0

    🧹 Nitpick comments (5)
    packages/angular-query-experimental/src/__tests__/inject-queries.test.ts (5)

    30-30: Rename suite to reflect the API under test.

    Name currently says "useQueries" but the test targets injectQueries.

    -describe('useQueries', () => {
    +describe('injectQueries', () => {

    69-71: Effect won’t react if proxies/array become stable (brittle to future optimizations).

    evaluateSignals uses untracked; the effect currently re-runs only because result() changes identity. If proxies/array are made stable (as intended), this will stop capturing updates. Track inner signals explicitly.

    -      _pushResults = effect(() => {
    -        results.push(this.result().map(evaluateSignals))
    -      })
    +      _pushResults = effect(() => {
    +        // Track inner signal values so the effect re-runs even with stable proxies/array
    +        const snapshot = this.result().map((q) => ({ data: q.data() }))
    +        results.push(snapshot)
    +      })

    26-28: Remove empty afterEach.

    No-op block with commented code; drop for cleanliness.

    -afterEach(() => {
    -  // vi.useRealTimers()
    -})
    +

    37-49: Template can avoid extra toString helper.

    Angular interpolation stringifies values; helper is unnecessary noise.

    -      template: `
    -        <div>
    -          <div>
    -            data1: {{ toString(result()[0].data() ?? 'null') }}, data2:
    -            {{ toString(result()[1].data() ?? 'null') }}
    -          </div>
    -        </div>
    -      `,
    +      template: `
    +        <div>
    +          <div>
    +            data1: {{ result()[0].data() ?? 'null' }}, data2: {{ result()[1].data() ?? 'null' }}
    +          </div>
    +        </div>
    +      `,
     ...
    -      toString(val: any) {
    -        return String(val)
    -      }

    74-81: Optional: use findByText for clearer async intent.

    Minor readability; functionally the same.

    -    await waitFor(() => rendered.getByText('data1: 1, data2: 2'))
    +    await rendered.findByText('data1: 1, data2: 2')
    📜 Review details

    Configuration used: CodeRabbit UI

    Review profile: CHILL

    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between 3d4612258bf2430eb269496bfa3e5626e0bc4da3 and d46ea2080b4a0697058b875aa85cf612f898a836.

    ⛔ Files ignored due to path filters (1)
    • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
    📒 Files selected for processing (4)
    • packages/angular-query-experimental/package.json (1 hunks)
    • packages/angular-query-experimental/src/__tests__/inject-queries.test.ts (1 hunks)
    • packages/angular-query-experimental/src/inject-queries.ts (8 hunks)
    • packages/angular-query-persist-client/package.json (1 hunks)
    🚧 Files skipped from review as they are similar to previous changes (1)
    • packages/angular-query-experimental/src/inject-queries.ts
    🧰 Additional context used
    🧠 Learnings (1)
    📚 Learning: 2025-09-02T17:57:33.184Z
    Learnt from: TkDodo
    PR: TanStack/query#9612
    File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
    Timestamp: 2025-09-02T17:57:33.184Z
    Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

    Applied to files:

    • packages/angular-query-persist-client/package.json
    • packages/angular-query-experimental/package.json
    🧬 Code graph analysis (1)
    packages/angular-query-experimental/src/__tests__/inject-queries.test.ts (2)
    packages/angular-query-experimental/src/inject-queries.ts (1)
    • injectQueries (221-331)
    packages/angular-query-experimental/src/__tests__/test-utils.ts (1)
    • evaluateSignals (10-29)
    ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
    • GitHub Check: Test
    🔇 Additional comments (2)
    packages/angular-query-persist-client/package.json (1)

    67-67: Confirm @testing-library/angular v18 requires Angular 20; verify monorepo

    • Confirmed: official v18 changelog raises the minimum Angular version to 20.
    • Action: ensure packages/angular-query-persist-client/package.json and every workspace package use @angular/core >= 20 (or pin @testing-library/angular to ^17).
    • Verification: automated repo scan here failed with fd/jq errors — re-run the package.json check locally and confirm all packages' @angular/core and @testing-library/angular versions.
    packages/angular-query-experimental/package.json (1)

    97-97: Approve — devDependency addition OK; compatibility and cross-package consistency verified.

    Testing Library v18 officially supports Angular 20 (Testing Library docs / README). Repository scan: ^18.0.0 appears only in packages/angular-query-experimental/package.json and packages/angular-query-persist-client/package.json — no conflicting majors detected.

  • Actionable comments posted: 0

    Caution

    Some comments are outside the diff and can’t be posted inline due to platform limitations.

    ⚠️ Outside diff range comments (1)
    packages/angular-query-experimental/src/__tests__/test-utils.ts (1)

    1-47: Restore or remove stale test helpers (expectSignals / evaluateSignals)

    test-utils no longer exports these helpers but tests and ESLint still reference them — update tests or reintroduce the helpers.

    • packages/angular-query-experimental/src/tests/test-utils.ts — current exports: setSignalInputs, setFixtureSignalInputs (no expectSignals/evaluateSignals).
    • packages/angular-query-experimental/src/tests/inject-infinite-query.test.ts — imports/calls expectSignals.
    • packages/angular-query-experimental/src/tests/inject-mutation.test.ts — imports/calls expectSignals (and imports setFixtureSignalInputs).
    • packages/angular-query-experimental/eslint.config.js — vitest/expect-expect assertFunctionNames includes 'expectSignals'.

    Action: either re-add the missing helpers to test-utils or update the tests to use the new helpers and remove 'expectSignals' from the ESLint config.

    ♻️ Duplicate comments (1)
    packages/angular-query-experimental/src/__tests__/test-utils.ts (1)

    1-1: Removal of evaluateSignals/expectSignals looks good and resolves the prior typing concern.

    🧹 Nitpick comments (5)
    packages/angular-query-experimental/src/__tests__/test-utils.ts (5)

    1-3: Avoid relying solely on private Angular signals API; prefer public .set(...) with a guarded fallback.

    @angular/core/primitives/signals is private and can break between Angular releases. Use inputSignal.set(value) when present, and fall back to signalSetFn(...[SIGNAL]) only if needed.

    - import { SIGNAL, signalSetFn } from '@angular/core/primitives/signals'
    + import { SIGNAL, signalSetFn } from '@angular/core/primitives/signals' // test-only fallback; prefer .set(...)
      import type { InputSignal } from '@angular/core'

    7-11: Make the updatable map Partial so callers can set a subset of inputs.

    As written, all InputSignal keys are required. Tests often set only a few.

    -type ToSignalInputUpdatableMap<T> = {
    -  [K in keyof T as T[K] extends InputSignal<any>
    -    ? K
    -    : never]: T[K] extends InputSignal<infer Value> ? Value : never
    -}
    +type ToSignalInputUpdatableMap<T> = Partial<{
    +  [K in keyof T as T[K] extends InputSignal<any>
    +    ? K
    +    : never]: T[K] extends InputSignal<infer Value> ? Value : never
    +}>

    13-20: Harden the type guard and avoid direct hasOwnProperty calls.

    Use Object.prototype.hasOwnProperty.call and coerce to boolean; widen key type to PropertyKey.

    -function componentHasSignalInputProperty<TProperty extends string>(
    -  component: object,
    -  property: TProperty,
    -): component is { [key in TProperty]: InputSignal<unknown> } {
    -  return (
    -    component.hasOwnProperty(property) && (component as any)[property][SIGNAL]
    -  )
    -}
    +function componentHasSignalInputProperty<TProperty extends PropertyKey>(
    +  component: object,
    +  property: TProperty,
    +): component is { [key in TProperty]: InputSignal<unknown> } {
    +  return (
    +    Object.prototype.hasOwnProperty.call(component, property) &&
    +    !!(component as any)?.[property]?.[SIGNAL]
    +  )
    +}

    26-35: Prefer .set(...); handle undefineds; avoid for..in prototype leaks.

    • Iterate via Object.entries and skip undefined values.
    • Use public set(...) when available; fallback to private signalSetFn for older versions.
    -export function setSignalInputs<T extends NonNullable<unknown>>(
    -  component: T,
    -  inputs: ToSignalInputUpdatableMap<T>,
    -) {
    -  for (const inputKey in inputs) {
    -    if (componentHasSignalInputProperty(component, inputKey)) {
    -      signalSetFn(component[inputKey][SIGNAL], inputs[inputKey])
    -    }
    -  }
    -}
    +export function setSignalInputs<T extends object>(
    +  component: T,
    +  inputs: ToSignalInputUpdatableMap<T>,
    +) {
    +  for (const [key, value] of Object.entries(inputs) as [keyof T, unknown][]) {
    +    if (value === undefined) continue
    +    if (componentHasSignalInputProperty(component, key as any)) {
    +      const sig = (component as any)[key]
    +      if (typeof sig?.set === 'function') {
    +        sig.set(value)
    +      } else {
    +        signalSetFn(sig[SIGNAL], value)
    +      }
    +    }
    +  }
    +}

    37-46: Loosen options shape and default to detectChanges: true.

    -export function setFixtureSignalInputs<T extends NonNullable<unknown>>(
    -  componentFixture: ComponentFixture<T>,
    -  inputs: ToSignalInputUpdatableMap<T>,
    -  options: { detectChanges: boolean } = { detectChanges: true },
    -) {
    -  setSignalInputs(componentFixture.componentInstance, inputs)
    -  if (options.detectChanges) {
    -    componentFixture.detectChanges()
    -  }
    -}
    +export function setFixtureSignalInputs<T extends object>(
    +  componentFixture: ComponentFixture<T>,
    +  inputs: ToSignalInputUpdatableMap<T>,
    +  options?: { detectChanges?: boolean },
    +) {
    +  setSignalInputs(componentFixture.componentInstance, inputs)
    +  if (options?.detectChanges ?? true) {
    +    componentFixture.detectChanges()
    +  }
    +}
    📜 Review details

    Configuration used: CodeRabbit UI

    Review profile: CHILL

    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between d6cb12dbba5de4d204c70b3f1dc09f862801d56c and 3f5156db7e6c6cb7eb6b3a7033498b402d80cde7.

    📒 Files selected for processing (2)
    • packages/angular-query-experimental/src/__tests__/inject-queries.test.ts (1 hunks)
    • packages/angular-query-experimental/src/__tests__/test-utils.ts (1 hunks)
    🚧 Files skipped from review as they are similar to previous changes (1)
    • packages/angular-query-experimental/src/tests/inject-queries.test.ts
  • @tomalaforge I merged this PR as it's definitely an improvement and long lived branches are a lot of work to keep up to date. However injectQueries isn't functional yet so can still be worked on. I moved it to a separate export so injectQueries won't hold up a stable release of the other APIs.

  • Sign in to join this conversation.