Get types for inline fragments #392
Answered
by
JoviDeCroock
ThomasKientz
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
JoviDeCroock
Sep 12, 2024
Replies: 1 comment 4 replies
-
That info is a bit insufficient but I'll assume that the field you are spreading a fragment on is abstract. In that case you need to narrow the type by doing __typename === typeCondition |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The fact that you are using an inline-fragment
... on X
here is becauseonboardCompanyAccountHolder
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