rtk-query: Modify refetchOnMountOrArgChange with enhanceEndpoints
See original GitHub issueI’m using codegen to generate the api spec and would like to specify a refetchOnMountOrArgChange
for the whole endpoint - rather than in every component.
Ideally I’d like to do something like
import { injectedApi } from './generated/api'
const enhancedRtkApi = injectedApi.enhanceEndpoints({
getData: {
refetchOnMountOrArgChange: 600,
keepUnusedDataFor: 14400,
},
},
})
export { enhancedRtkApi as api }
But it looks like refetchOnMountOrArgChange
is part of the query
key. I may be missing something, but I couldn’t figure out a way to pass query
key w/o overriding the generated one
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Queries - Redux Toolkit
RTK Query > Usage > Queries: fetching data from a server. ... Query endpoints may also modify the response contents before the result...
Read more >RTK Query Best Practices - Medium
RTK Query is responsible for: Fetching data and keeping cached data on the client-side. Mutating data (create/update/delete) and syncing the changes from the ......
Read more >Introduction to Redux Toolkit Query with TypeScript
On top of that, RTK Query generates React hooks ready to use. ... When we want to alter the data on the server,...
Read more >redux-starter-kit - Bountysource
Investigate RTK Query-specific additions to the Redux DevTools Extension $ 0 ... enhanceEndpoints({ getData: { refetchOnMountOrArgChange: 600, ...
Read more >What argument must change in order for refetching to occur ...
To quote the official Redux Toolkit Query documentation for 'refetchOnMountOrArgChange' here: I.e., when the component calling ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah I re-checked the source - you can either define it for the full api, or on the hook call, but not on the endpoint. My bad.
I’m getting a TS error with that: