Skip to content

How to represent nested union? #2349

Answered by mikekistler
RafalFilipek asked this question in Q&A
Discussion options

You must be logged in to vote

Here's a suggestion:

model Foo {type: "FOO"}
@discriminator("role")
model Bar {
  type: "BAR"
}
model BarA extends Bar {type: "BAR", role: "A"}
model BarB extends Bar {type: "BAR", role: "B"}
model Biz {type: "BIZ"}

@discriminator("type")
union Items {
  FOO: Foo,
  BAR: Bar,
  BIZ: Biz,
}

Playground link

Is this what you wanted?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by markcowl
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