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

generated code has incorrect type for error #710

Open
mcheng-brilliant opened this issue Aug 16, 2023 · 0 comments
Open

generated code has incorrect type for error #710

mcheng-brilliant opened this issue Aug 16, 2023 · 0 comments

Comments

@mcheng-brilliant
Copy link

mcheng-brilliant commented Aug 16, 2023

The generated code collapses the different possible errors into a single error property in the response:

From the test spec:

error: data?.error ?? data?.errors ?? null,

In that line of code:

  • data?.error is of type: Apollo.ApolloError | undefined
  • data?.errors is of type: ReadonlyArray<GraphQLError> | undefined
  • and both are nullish coalesced into null

The resulting type should be a compound type of those possibilities. However, the generated code incorrectly types this as error?: Apollo.ApolloError:

`export type PageFeedComp = React.FC<{data?: FeedQuery, error?: Apollo.ApolloError}>;`

Expected Behavior

  • Generated code types error as Apollo.ApolloError | readonly GraphQLError[] | null.
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

1 participant