Re-architect Angular Query around Angular Resource before stable release #10788
Unanswered
OmerGronich
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’d like to propose making Angular Resource part of the core implementation of
injectQuery.The Angular adapter is still experimental, and when it was created Angular did not yet have a first-party Resource API. Now Angular does, and newer Angular APIs are starting to compose around resources. Signal Forms async validation is a good example:
validateAsync()is resource-based, butinjectQuery()currently returns a TanStack-shaped signal object, not a resource.That makes TanStack Query feel slightly outside Angular’s current async model. It works well with signals and templates, but it does not plug cleanly into APIs that expect a
ResourceRef.Proposal
Architect
injectQueryaround Angular Resource internally:The public API could remain mostly the same:
But because the implementation is resource-based, the underlying resource could also be exposed:
This would let Angular-native APIs consume TanStack Query without custom glue:
Why this should be part of the architecture
Angular signals are the reactivity primitive. Angular Resource is the async primitive.
injectQuery()currently integrates with the former, but not really with the latter.The Solid adapter is a useful comparison: it keeps the Query API, but integrates with Solid’s native async primitive under the hood. Angular now has its own equivalent async primitive, so it seems worth considering the same direction before the Angular adapter stabilizes.
The goal is not to hide TanStack Query behind Resource. TanStack Query still has important semantics that Resource does not fully capture, like stale state, background refetching, invalidation, retries, paused fetches, placeholder data, cache metadata, and separate
status/fetchStatus.So the returned object could expose both layers:
Open questions
injectQuery()be resource-based internally?query.resource,query.asResource(), or something else?query.data()come fromresource.value(), or should both come from a shared observer snapshot?statusandfetchStatusmap to AngularResourceStatus?resource.reload()map toquery.refetch()?resource.set()andresource.update()map toqueryClient.setQueryData()?injectInfiniteQuery()follow the same model?Since the Angular adapter is still experimental, this feels like the right time to decide whether it should be resource-first internally before the API stabilizes.
Beta Was this translation helpful? Give feedback.
All reactions