-
Should Lazy Queries Auto-Refetch on Cache Tag Invalidation?QuestionHi RTK Query team! I have a question about lazy query behavior with cache tags. Currently, lazy queries ( Why We Use Tags with Lazy QueriesWe use
Since both queries share the same endpoint definition, we can't configure them differently. We need tags for regular queries, but we're wondering if lazy queries should auto-refetch. Current BehaviorWhen a lazy query is executed and cached with tags, RTK Query automatically refetches it when those tags are invalidated, even though:
Should lazy queries:
About
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Yes, they should. The lazy thing about lazy queries is that they don't do the initial request at component mount, but after that they behave like a normal query in any way. They do not "only do requests when called", they are just "lazily initialized queries". |
Beta Was this translation helpful? Give feedback.
-
|
@phryneas can probably give a better answer because he designed RTKQ and lazy queries in the first place, but in general I'd say: The "laziness" in a lazy query is solely about initiating the first request. In other words, it's roughly similar to having Once the query cache entry exists, all the normal RTKQ behavior rules apply as usual. (aaaand I see he just replied with that same response.) |
Beta Was this translation helpful? Give feedback.
Yes, they should.
The lazy thing about lazy queries is that they don't do the initial request at component mount, but after that they behave like a normal query in any way.
They do not "only do requests when called", they are just "lazily initialized queries".