dotansimha / dotansimha/graphql-code-generator

support `useSuspenseQuery` from react-query v5

Open
#9,786 6 comments 4 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Is your feature request related to a problem? Please describe.

I'm upgrading my application from react-query v4 to v5.

I've added the `reactQueryVersion: 5` to my codegen config, and solved most issues.

However react-query v5, has deprecated the `suspense: boolean` option on `useQuery` in favor of a separate `useSuspenseQuery` hook.

This means all of my queries that did use `suspense: true` are now broken, since `graphql-codegen` generate all my queries as `useQuery`.

I saw a similar issue was created, but that was specifically for `apollo` which has a workaround. I don't use apollo, I use `react-query`, so unfortunately the solution there is not helpful.

### Describe the solution you'd like

I'm not entirely sure what the best solution to this problem is. Ideally I would like to be able to make "some" but not all of my queries use `suspense`.

Essentially I need it to generate a `useSuspenseQuery` for some queries, instead of `useQuery`.

### Describe alternatives you've considered

From the changelog and migration steps. I don't see any other alternative ways to accomplish this? But please let me know if there's a way.

Edit: I asked Tanner Linsley (creator of react-query) he confirmed there's no other way to do this now, and `graphql-code-generator` should update to use `useSuspenseQuery` when needed.

### Is your feature request related to a problem? Please describe.

https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#new-hooks-for-suspense

https://tanstack.com/query/latest/docs/react/guides/suspense

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.