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 object spread regression #1065

Closed
onsoup42 opened this issue Oct 4, 2021 · 0 comments · Fixed by #1066
Closed

Scala 3 object spread regression #1065

onsoup42 opened this issue Oct 4, 2021 · 0 comments · Fixed by #1066
Labels
bug Something isn't working server Issue related to caliban server

Comments

@onsoup42
Copy link

onsoup42 commented Oct 4, 2021

Caliban running under Scala 3 cannot handle object spreads without a space between ... and on.
This code produces different results on Scala 2 and Scala 3

object Main extends zio.App {
  case class Foo(bar: String)
  case class Query(foo: Foo)
  val api = caliban.GraphQL.graphQL(caliban.RootResolver(Query(Foo("bar"))))

  val queryWithSpace    = "{foo{... on Foo{bar}}}"
  val queryWithoutSpace = "{foo{...on Foo{bar}}}"

  override def run(args: List[String]) = (for {
    interpreter <- api.interpreter
    withSpace <- interpreter.execute(queryWithSpace)
    withoutSpace <- interpreter.execute(queryWithoutSpace)
    _ = println(withSpace)
    _ = println(withoutSpace)
  } yield ()).exitCode

}

Dependencies:
libraryDependencies += "com.github.ghostdogpr" %% "caliban" % "1.1.1"

Scala 2.13.3 output

GraphQLResponse({"foo":{"bar":"bar"}},List(),None)
GraphQLResponse({"foo":{"bar":"bar"}},List(),None)

Scala 3.0.6 output

GraphQLResponse({"foo":{"bar":"bar"}},List(),None)
GraphQLResponse(null,List(Parsing Error: Parsing error at offset 10, expected: Fail(10) ),None)

This might looks look like a small problem but it's not. It turns out that the Apollo gateway will generate queries without the space. Preventing federated caliban servers from upgrading to Scala 3.

@ghostdogpr ghostdogpr added bug Something isn't working core server Issue related to caliban server labels Oct 4, 2021
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.

2 participants