Use case
Given a Union like:
union SomeUnion = FirstCase|SecondCase|ThirdCase
And a type:
type TypeContent {
content: SomeUnion!
}
And in my query I got:
fragment "" on "" {
content {
...ContentFragment
}
}
fragment ContentFragment on SomeUnion {
...FirstFragment
...SecondFragment
...ThirdFragment
}
Then in my code at some point I am doing:
fun ContentFragment.toFoo(): Foo {
when(this) {
is FirstFragment -> ...
is SecondFragment -> ...
is ThirdFragment -> ...
else ->
}
}
Describe the solution you'd like
That else in the last function means that if a new Union type is added to my schema my code won't catch the fact that I am not handling the new case, since it is "covered" by the else ->
Improving this to be part of a sealed hierarchy would be a great way to prevent accidentally making such a mistake