[WIP] Angular injectQueries fixes
This PR:
- Fixes the types of
injectQueries - Add type tests for
injectQueries - Adds initial tests for
injectQueriesruntime - Fixes runtime behavior of
injectQueries
TODO:
- [ ] Figure out where to add
signalProxy
View your CI Pipeline Execution ↗ for commit 26d7f36575dcc568a2c110d7b4497361a8f270f6
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
✅ Succeeded | 1m 41s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 8s | View ↗ |
☁️ Nx Cloud last updated this comment at 2025-09-18 17:42:21 UTC
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-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-simple
- @tanstack/query-example-solid-start-streaming
- @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-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-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@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
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?
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>
More todos:
- [ ] Should be able to throw an error when
throwOnErroris true - [ ] Using
mapon 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
@arnoud-dv @crutchcorn Are you still working on the feature? Do you need some help?
Yes, help with injectQueries is welcome Thomas. I don't have enough time at the moment.
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 depspackages/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 refactorpackages/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 testspackages/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 testspackages/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
Possibly related issues
- TanStack/query#8703 — Tracks the injectQueries refactor and API/type changes implemented here.
Possibly related PRs
- 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 name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The 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 | ✅ Passed | No 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.
Comment @coderabbitai help to get the list of available commands and usage tips.
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
@@ 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
: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.
@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.