Open mvdstam opened 1 month ago
I suspect that PR that introduced SkipToken
support is going to need to be reverted. It suffers from the problem outlined in the original issue.
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.
@saihaj
Can you please take a look at this, since https://github.com/dotansimha/graphql-code-generator-community/pull/835 most definitely introduced a breaking change? :+1:
Which packages are impacted by your issue?
@graphql-codegen/typescript-react-apollo
Describe the bug
Hi,
Since https://github.com/dotansimha/graphql-code-generator-community/pull/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