Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3 different schema derivation nested types #1989

Closed
guymers opened this issue Nov 8, 2023 · 0 comments · Fixed by #1991
Closed

Scala 3 different schema derivation nested types #1989

guymers opened this issue Nov 8, 2023 · 0 comments · Fixed by #1991
Assignees
Labels
bug Something isn't working server Issue related to caliban server

Comments

@guymers
Copy link
Contributor

guymers commented Nov 8, 2023

The following produces a different schema depending on the Scala version:

sealed trait Level1
object Level1 {
  implicit val schema: Schema[Any, Level1] = Schema.gen

  sealed trait Level2 extends Level1
  object Level2 {
    implicit val schema: Schema[Any, Level2] = Schema.gen

    case class Level3(value: Boolean) extends Level2
    object Level3 {
      implicit val schema: Schema[Any, Level3] = Schema.gen
    }
  }
}

case class Queries(
  level: Level1,
)
object Queries {
  implicit val schema: Schema[Any, Queries] = Schema.gen
}

val schema = {
  val queries = Queries(level = Level1.Level2.Level3(false))
  caliban.graphQL(RootResolver(queries))
}

Scala 2:

schema {
  query: Queries
}

union Level1 = Level3

type Level3 {
  value: Boolean!
}

type Queries {
  level: Level1!
}

Scala 3:

schema {
  query: Queries
}

enum Level1 {
  Level2
}

type Queries {
  level: Level1!
}
@guymers guymers changed the title Scala 3 different schema derivation Scala 3 different schema derivation nested types Nov 8, 2023
@kyri-petrou kyri-petrou self-assigned this Nov 8, 2023
kyri-petrou added a commit that referenced this issue Nov 8, 2023
kyri-petrou added a commit that referenced this issue Nov 8, 2023
@ghostdogpr ghostdogpr added bug Something isn't working server Issue related to caliban server core labels Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Issue related to caliban server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants