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 enum names #1990

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

Scala 3 different schema derivation enum names #1990

guymers opened this issue Nov 8, 2023 · 2 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:

@GQLName("PrefixOperator")
sealed trait Operator
object Operator {
  @GQLName("PrefixOperatorGreaterThan")
  case object GreaterThan extends Operator {
    implicit val schema: Schema[Any, GreaterThan.type] = Schema.gen
  }

  @GQLName("PrefixOperatorLessThan")
  case object LessThan extends Operator {
    implicit val schema: Schema[Any, LessThan.type] = Schema.gen
  }

  implicit val schema: Schema[Any, Operator] = Schema.gen
}

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

val schema = {
  val queries = Queries(op = Operator.LessThan)
  caliban.graphQL(RootResolver(queries))
}

Scala 2:

schema {
  query: Queries
}

enum PrefixOperator {
  PrefixOperatorGreaterThan
  PrefixOperatorLessThan
}

type Queries {
  op: PrefixOperator!
}

Scala 3:

schema {
  query: Queries
}

enum PrefixOperator {
  GreaterThan
  LessThan
}

type Queries {
  op: PrefixOperator!
}
@kyri-petrou kyri-petrou self-assigned this Nov 8, 2023
kyri-petrou added a commit that referenced this issue Nov 8, 2023
@kyri-petrou
Copy link
Collaborator

Thanks for reporting these issues - our Scala 3 derivation uses Scala 3's built-in generic derivation instead of Magnolia. While this gives us more flexibility, it also means that we have a few inconsistencies / small bugs in some edge cases

kyri-petrou added a commit that referenced this issue Nov 8, 2023
@guymers
Copy link
Contributor Author

guymers commented Nov 8, 2023

No worries, thanks for the fixing them so quickly.

@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