dotansimha / dotansimha/graphql-code-generator-community
[React query] Expose fetcher for infinite queries.
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
**Is your feature request related to a problem? Please describe.**
It would be useful, for prefetching infinite queries, to expose the fetcher for infinite queries in addition to the `getKey` method. It appears that even when `exposeFetcher` is set to true in config, the fetcher is not being generated for useInfiniteWhateverQuery.
**Describe the solution you'd like**
Similar to how `exposeQueryKeys` config works, `exposeFetcher` should also expose the fetcher for infinite queries if `addInfiniteQuery` is also true. I would like to be able to do this in my `getServersideProps`
```typescript
const queryClient = new QueryClient();
await queryClient.prefetchInfiniteQuery(
useInfiniteWhateverQuery.getKey(),
useInfiniteWhateverQuery.fetcher({ pageSize: 20 })
);
let state = dehydrate(queryClient);
return {
props: {
dehydratedState: state,
},
};
```
**Describe alternatives you've considered**
I could probably hack my way around this by using the non infinite query fetcher, and then hydrating the first page of the infinite query manually with this data but it wouldn't be pretty.
**Additional context**
The above code snippet works like a charm for non infinite queries, the only missing piece now is to expose the fetcher on infinite queries.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the infinite-query generation and the exposeFetcher and exposeQueryKeys configuration handling, then compare it with the existing non-infinite fetcher generation. Done means that when exposeFetcher and addInfiniteQuery are enabled, the generated infinite-query hook exposes a fetcher usable with prefetchInfiniteQuery as shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100