-
-
Notifications
You must be signed in to change notification settings - Fork 117
feat/bugfix: fixing-import-fixing-reactivity #2220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat/bugfix: fixing-import-fixing-reactivity #2220
Conversation
📝 WalkthroughWalkthroughUpdates the Angular TanStack Query integration: generator now allows args as a value or function for Angular and switches Angular imports to the experimental package. Runtime hooks resolve args that may be functions, refactor query construction to return injected query objects, and adjust return typing by relying on inference. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Component
participant H as useModelQuery
participant Q as injectQuery
C->>H: call(args | () => args)
H->>H: resolve args (isFn ? args() : args)
H->>H: build queryKey and reqUrl from resolvedArgs
H->>Q: injectQuery({ queryKey, queryFn })
Q-->>H: QueryObject
H-->>C: QueryObject
sequenceDiagram
participant C as Component
participant H as useInfiniteModelQuery
participant IQ as injectInfiniteQuery
C->>H: call(args | () => args)
H->>H: resolve args
H->>H: build infinite queryKey and page URL from resolvedArgs
H->>IQ: injectInfiniteQuery({ initialPageParam: resolvedArgs, queryFn })
IQ-->>H: InfiniteQueryObject
H-->>C: InfiniteQueryObject
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (5)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Problem
Angular has a unique initialization timing issue where component inputs (route params, etc.) are not available during class initialization. This causes runtime errors when query hooks try to access these values immediately:
Additionally, even when we remove the required which "fixes" the error because undefined is then expected, the query doesn't react to changes since the args were evaluated only once at initialization.
(This does also apply to normal angular signals )
Solution
Allow query args to be passed as a function for Angular target, enabling deferred evaluation and reactivity:
what also works with this changes
Changes
Modified generateQueryHook to accept args | (() => args) for Angular target
Modified useModelQuery to resolve the args inside the injectQuery for reactivity.
Modified useInfiniteModelQuery to resolve the args inside the injectQuery for reactivity.
Updated Angular imports to use @tanstack/angular-query-experimental
Maintains backward compatibility for other frameworks
No breaking changes
Solves both timing issues and enables full reactivity with Angular signals.
Also aligns now more with
https://tanstack.com/query/latest/docs/framework/angular/examples/router
Other Changes
Fixed makeBaseImports for target Angular