Skip to content

Get types for inline fragments #392

Answered by JoviDeCroock
ThomasKientz asked this question in Q&A
Discussion options

You must be logged in to vote

The fact that you are using an inline-fragment ... on X here is because onboardCompanyAccountHolder is returning an abstract type which is either the success or error variant. You are asking it to show you the success variant and for errors you won't receive anything.

Now TypeScript ofcourse knows that this can have two variants so you'll have to narrow the type by doing the following

    mutation MyQuery {
      onboardCompanyAccountHolder(
        input: { companyType: Company, isRegistered: true, accountName: "12 rue" }
      ) {
        __typename ## notice this, this can be OnboardCompanyAccountHolderSuccessPayload or the error variant
        ... on OnboardCompanyAccountHolderSucces…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ThomasKientz
Comment options

@ThomasKientz
Comment options

@JoviDeCroock
Comment options

Answer selected by ThomasKientz
@ThomasKientz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants