Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useSuspenseQuery support #388

Closed
simPod opened this issue Aug 10, 2023 · 9 comments
Closed

useSuspenseQuery support #388

simPod opened this issue Aug 10, 2023 · 9 comments

Comments

@simPod
Copy link

simPod commented Aug 10, 2023

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

Add support for useSuspenseQuery introduced in apollographql/apollo-client#10323

Describe the solution you'd like

Allow to generate useSuspenseQuery hooks instead/additionally to current useQuery hooks

Describe alternatives you've considered

No response

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

No response

@chazmuzz
Copy link

Please also add support for useBackgroundQuery which was also introduced in Apollo v3.8 to avoid request waterfalls: https://www.apollographql.com/docs/react/data/suspense#avoiding-request-waterfalls

@saihaj saihaj transferred this issue from dotansimha/graphql-code-generator Aug 25, 2023
@saihaj
Copy link
Collaborator

saihaj commented Aug 25, 2023

would you like to send in a PR?

@saihaj
Copy link
Collaborator

saihaj commented Oct 25, 2023

@saihaj saihaj closed this as completed Oct 25, 2023
@Hal-ang
Copy link
Contributor

Hal-ang commented Oct 25, 2023

Thank you @Hal-ang! @graphql-codegen/[email protected]

I'm so happy~~ Thank you ☺️

@fforres
Copy link

fforres commented Oct 25, 2023

This is great! Thanks for all the work @Hal-ang @saihaj 🙏

@fforres
Copy link

fforres commented Oct 31, 2023

Made a follow-up issue for useBackgroundQuery and useReadQuery here #477

@fresonn
Copy link

fresonn commented Jan 9, 2024

So, how can I disable it in config?

@vasilev-alex
Copy link

So, how can I disable it in config?

didn't find this option, had to revert to the previous version

@gynekolog
Copy link

The workaround might be to use codemod to remove all SuspenseQuery functions and types.
There's one I use.

draftcode added a commit to draftcode/graphql-code-generator-community that referenced this issue Aug 7, 2024
…ableQuery

Implement `useBackgroundQuery` and `useLoadableQuery` hooks for React
Apollo. These APIs are added in 3.8.0 and 3.9.0 respectively.

Suspense support in Apollo Client provides 5 new hooks as described in
https://www.apollographql.com/docs/react/data/suspense/.
`useSuspenseQuery` support was added in
dotansimha#434.
Among other 4 hooks, `useBackgroundQuery` and `useLoadableQuery` are
the ones that take a GraphQL document as an argument like other existing
hooks. The support for these hooks are added in this change.

Other hooks, `useQueryRefHanders` and `useReadQuery` do not take a
GraphQL document as an argument, so they do not need to be added as the
generated code. Both take the return values of other hooks as an
argument, and the types are inferred from it.

Follow up to
dotansimha#388.
Fixes dotansimha#477.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants