Angular DI for Module-Specific QueryClient Default Options (Without New Instance) #9041
Unanswered
irisDreizen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm working with
@tanstack/angular-query-experimental
in a large Angular application and exploring ways to manage query configurations effectively across different feature modules.My goal is to have slightly different default behaviors (e.g.,
staleTime
,gcTime
) for queries initiated within specific feature modules compared to the application-wide defaults set on theQueryClient
provided globally via provideAngularQuery.However, a key requirement is to achieve this without creating and providing a new, separate
QueryClient
instance for each module usingprovideQueryClient
. I want all queries throughout the application to utilize the single, sharedQueryClient
instance and its cache, but I'd like to know if the defaults it applies can be influenced by the Angular DI scope of the consuming service/component.I understand the standard approaches are:
injectQuery
call, often facilitated by a service using thequeryOptions
helper.queryClient.setQueryDefaults
based onqueryKey
prefixes.provideQueryClient
to introduce a separate, isolated client instance (which I want to avoid).My specific question is: Is there any intended or supported mechanism using Angular's hierarchical Dependency Injection system where providers within a feature module could alter or override the
defaultOptions
inherited from the single, globally providedQueryClient
instance, specifically for consumers within that module's injector scope?Essentially, I'm wondering if a module's DI configuration can act as a layer to modify the effective defaults applied by the global
QueryClient
for queries originating within that module, rather than just overriding them explicitly at theinjectQuery
call site.Thanks for any insights or clarification on this pattern!
Beta Was this translation helpful? Give feedback.
All reactions