-
Notifications
You must be signed in to change notification settings - Fork 161
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 data possibly undefined #838
Comments
I suspect that PR that introduced No shade to the developer that implemented it, as they were trying to be useful, but the implementation is perhaps a bit too naive. This perhaps shows that the tests may not be covering what needs to be tested in regards to suspense hook functionality, as this is a breaking change that essentially undoes the entire point of using suspense hooks. |
…ned by useSuspenseQuery
Which packages are impacted by your issue?
@graphql-codegen/typescript-react-apollo
Describe the bug
Hi,
Since #835 and after updating
@graphql-codegen/typescript-react-apollo
to4.3.2
, all of our suspense hooks now return data that are possibly 'undefined', breaking compilation:Before:
Now:
I'm not sure whether or not this is a bug, or that there is an additional step necessary on my end to make typescript understand that in the above examples, we're not skipping the query using a
skipToken
. Only when passing theskipToken
in the hook should the return type be possibly undefined.Perhaps @jefrydco can shed some light on this? Is there any more configuration necessary to support the
skipToken
variable in generated suspense hooks?Cheers!
Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
Upgrade to
@graphql-codegen/typescript-react-apollo v4.3.2
when using generated useSuspenseQuery hooksExpected behavior
I expected the return type of
data
for auseGetMyDataSuspenseQuery
be eitherGetMyData
orGetMyData | undefined
, depending on whether or not askipToken
is present. Existing code not containing askipToken
in the hook should have the same return types as before upgrading to@graphql-codegen/typescript-react-apollo v4.3.2
.Screenshots or Videos
No response
Platform
graphql
version: 16.8.1@graphql-codegen/*
version(s):Codegen Config File
Additional context
No response
The text was updated successfully, but these errors were encountered: