Skip to content

generated code has incorrect type for error #710

@mcheng-brilliant

Description

@mcheng-brilliant

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions