Skip to content

[Kotlin] Ability to generate sealed interfaces#869

Merged
kobylynskyi merged 12 commits into
kobylynskyi:developfrom
kbrooks:develop
Dec 2, 2021
Merged

[Kotlin] Ability to generate sealed interfaces#869
kobylynskyi merged 12 commits into
kobylynskyi:developfrom
kbrooks:develop

Conversation

@kbrooks

@kbrooks kbrooks commented Nov 17, 2021

Copy link
Copy Markdown
Contributor

Description

Adds sealed keyword to generated interfaces and unions in order to enable exhaustive type-checking in written code. Only works in and in Kotlin, even though Scala has support for sealed interfaces, because Scala has the restriction that classes inheriting a sealed interface are in the same file as that interface. Java has support for sealed interfaces but requires a permits A, B, ... syntax that makes it more difficult to support since we would need to parse the entire schema for all values that implement a given interface.

Related to #868


Changes were made to:

  • Codegen library - Java
  • Codegen library - Kotlin
  • Codegen library - Scala
  • Maven plugin
  • Gradle plugin
  • SBT plugin

@kbrooks

kbrooks commented Nov 17, 2021

Copy link
Copy Markdown
Contributor Author

Sonar is failing for mysterious reasons

Comment thread docs/codegen-options.md Outdated
@kbrooks kbrooks changed the title [Kotlin] Ability to generate sealed interfaces [Java] [Kotlin] Ability to generate sealed interfaces Nov 17, 2021
@kbrooks

kbrooks commented Nov 17, 2021

Copy link
Copy Markdown
Contributor Author

java interface is missing "permits"

Kyle added 2 commits November 17, 2021 15:28
This reverts commit b865fce.
This reverts commit 23c2f30.
@kbrooks kbrooks changed the title [Java] [Kotlin] Ability to generate sealed interfaces [Kotlin] Ability to generate sealed interfaces Nov 17, 2021

@kobylynskyi kobylynskyi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@kobylynskyi kobylynskyi added this to the 5.3.1 milestone Dec 2, 2021
@kobylynskyi kobylynskyi merged commit d6bd6b4 into kobylynskyi:develop Dec 2, 2021
@kobylynskyi kobylynskyi linked an issue Dec 2, 2021 that may be closed by this pull request
aldib added a commit to aldib/graphql-java-codegen that referenced this pull request Dec 7, 2021
Co-authored-by: Kyle <kbrooks@github.com>
aldib added a commit to aldib/graphql-java-codegen that referenced this pull request Dec 7, 2021
Co-authored-by: Kyle <kbrooks@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support "sealed" keyword on interfaces and unions in Kotlin

2 participants