Repository navigation
RTK Query usage feedback for 2.x planning #5534
Replies: 2 comments 4 replies
|
needs features like subs on cache key, like in tanstack-query. needs fix generated hooks export, now if use... hook from api exported as {use...} in IDE jump to source not follow to api creator, stops only on export. Now i using hooks like api.endpoints.post...useQuery(). Click to post... jump in ide to field in api creator. also with initiate, on tanstack-router i dispatch some data like .initiate() with unsub or manual call. We use codegen from openapi like contract and fetch layer. needs improve rtk query codegen like kubb.dev for tanstack-query. |
|
Reading the cache directly
In a very specific edge-case do we use initiate() promises and request timing
Again to solve a very specific problem we where facing. 3 cases in one app and 1 case in another. All of them steming from the same problem, we need to fetch data outside of react scope.
All of these are used in some combination or other in the examples above. Invalidation while a request is pending
I don't think we have ever encountered a problem with this but as a though experiment I guess refetch after it finishes would make sense?
Again I don't think we ever encountered a problem with this. And honestly I don't know. I feel like this would be a case-by-case thing. I don't think you can say categorically that one way or the other is the best solution. I would expect that once you run into this problem you have a very specific edge-case and would need to be able use the solution that matches your edge-case. So configurable would probably be the way to go here. SSR, hydration and persistence
We don't use extractRehydrationInfo, instead we initialize the entire store with preloadedState as hydration. Our setup is custom built.
We do persist the logged in customer and carts in local storage so we can sync them across tabs.
No. Not found a use-case for that yet. Thanks for all your hard work! |
Uh oh!
There was an error while loading. Please reload this page.
We're starting on the RTK Query work in the 2.x and 3.0 roadmap. Several of the upcoming 2.x releases change how RTKQ tracks requests and writes to the cache. Before we lock in those behaviors, we'd like to know how you actually use them today.
Real code examples help the most, even short snippets. "We do X because Y" is more useful to us than "X would be nice".
Reading the cache directly
state.api.queriesorstate.api.mutationsdirectly, instead of through the endpoint selectors? What for?In 3.0 the query cache moves to
queries[endpointName][cacheKey](#5503), so we want to know what that breaks and what selectors or utilities would replace your current code.initiate()promises and request timingawait dispatch(api.endpoints.x.initiate(arg))and use the value it resolves to? What happens if that request was deduped against one already in flight?forceRefetch,subscribe: false, or manualunsubscribe()calls? What for?In 2.15 the
initiate()promise always resolves with the result of its own request (#5506). That's a behavior change, so we want to know who depends on the current behavior.Invalidation while a request is pending
updateQueryDataorupsertQueryDatawhile a fetch for that entry is in flight, which result do you expect to win?These answers feed directly into the invalidation work (#5510, #5511) and into which of these behaviors becomes the default.
SSR, hydration and persistence
extractRehydrationInfo? With which setup (Next.js pages or app router, redux-persist, something custom)?We plan to add
dehydrate/hydrateutilities in 2.17 (#5515), and they will be the supported way to carry cache data across the 3.0 upgrade.Answers on any subset of these are welcome. Feedback on the 3.0 API changes goes in [the 3.0 breaking changes discussion].
All reactions