The Kotlin2 codegen already generates sealed interface for GraphQL interfaces and unions. The Java path still generates plain interface + mutable POJOs.
It'd be nice if you generated sealed interfaces in Java too, since that's the closest match to what is expressed in GQL by an interface or union.
Concrete example from our schema:
interface INKSIGHT_OcrJob { ... }
type INKSIGHT_OcrJobCompleted implements INKSIGHT_OcrJob { corpusUrl: BagginsUrl! }
type INKSIGHT_OcrJobPending implements INKSIGHT_OcrJob { }
type INKSIGHT_OcrJobFailed implements INKSIGHT_OcrJob { message: String! }
Today this generates a plain interface + 3 mutable POJOs. What we want:
public sealed interface INKSIGHT_OcrJob
permits INKSIGHT_OcrJobCompleted, INKSIGHT_OcrJobPending, INKSIGHT_OcrJobFailed { ... }
public record INKSIGHT_OcrJobCompleted(...) implements INKSIGHT_OcrJob { }
// etc.
That would give us exhaustive switch in Java 21+, immutability by default, and the compiler enforcing what the schema already guarantees.
The Kotlin2 codegen already generates sealed interface for GraphQL interfaces and unions. The Java path still generates plain interface + mutable POJOs.
It'd be nice if you generated sealed interfaces in Java too, since that's the closest match to what is expressed in GQL by an interface or union.
That would give us exhaustive switch in Java 21+, immutability by default, and the compiler enforcing what the schema already guarantees.