fix(angular-query): honor per-query 'throwOnError' in 'injectQueries' 🤖🤖🤖 - #11405
fix(angular-query): honor per-query 'throwOnError' in 'injectQueries' 🤖🤖🤖#11405ousamabenyounes wants to merge 1 commit into
Conversation
injectQueries never evaluated throwOnError, so a failing query with throwOnError set was silently reduced to an error result. Resolve the option per query in the QueriesObserver subscriber and rethrow, the way injectQuery already does in createBaseQuery. Results are published to the signal before the throw so the failing query's own error state and its healthy siblings still update.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesAngular injectQueries error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to injectQueries now applies throwOnError per failing query while preserving published error and sibling-query states before rethrowing. The covered behavior is ready to merge with no identified current risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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. Comment |
🎯 Changes
injectQueriesnever looked atthrowOnError. ItsQueriesObserversubscriber wrote everynotification straight into the result signal, so a query failing with
throwOnError: truewassilently reduced to an error result — nothing was thrown, and nothing reached Angular's error
handling.
injectQueryalready handles this increate-base-query.ts: it callsshouldThrowErrorwiththe query's own
throwOnError, emits onNgZone.onError, and rethrows. This applies the samehandling in
injectQueries, resolving the option per query — each entry in the array carriesits own
throwOnError, so the query that opts in is the one that throws, checked against its ownerror and its own
Query.react-query'suseQueriesresolves it per query the same way.The results are published to the signal before the throw.
throwOnErrormeans "also throw", sothe failing query's own
status()/error()and its healthy siblings must still update; throwingfirst would leave the whole array frozen at its previous value.
Behaviour without
throwOnErroris unchanged — the errored result still flows into the resultsignal, which the existing
should reflect error state when one of the queries rejectstest covers.This is one item from the
injectQueriesTODO list left on #8704 ("Should be able to throw anerror when
throwOnErroris true"). The other items there are untouched, so this does not closethe issue, and the "under development" note in the Angular parallel-queries guide still applies.
Test verification (RED → GREEN)
Run the
angular-query-experimentalpackage'stest:libtarget from the repo root throughNx, filtered to
inject-queries.RED — the three new tests against unmodified
main(production file reverted, tests kept):GREEN — same command with the change applied:
Full local suite
Replayed the
pr.ymltarget set (test:sherif,test:knip,test:docs,test:eslint,test:lib,test:types,test:build,build) over the affected projects, onmainand onthis branch:
mainNo type errors, no lint errors, no new failures.
test:typespasses on TS 5.6/5.7/5.8/5.9/current/7.0.
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
injectQueriesnow honors each query’sthrowOnErrorsetting.Documentation