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

Broken backward compatibility in CatsInterop since v2.7.0 #2295

Closed
satorg opened this issue Jun 19, 2024 · 1 comment
Closed

Broken backward compatibility in CatsInterop since v2.7.0 #2295

satorg opened this issue Jun 19, 2024 · 1 comment

Comments

@satorg
Copy link
Contributor

satorg commented Jun 19, 2024

Consider a reproducer:

import caliban.interop.cats.implicits._
import caliban.schema.Schema.auto._
import caliban.{RootResolver, graphQL}
import cats.effect.std.{Console, Dispatcher}
import cats.effect.{IO, IOApp}
import zio.Runtime

case class Queries(one: IO[String])

object ExampleApp extends IOApp.Simple {
  implicit val zioRuntime: Runtime[Any] = Runtime.default

  override def run: IO[Unit] =
    Dispatcher.parallel[IO].use { implicit dispatcher =>
      val rendered = graphQL(RootResolver(Queries(IO.pure("")))).render

      Console[IO].println(rendered)
    }
}

With Caliban versions up to v2.6.0 (inclusive), the output is the following:

schema {
  query: Queries
}
type Queries {
  one: String!
}

Starting with Caliban v2.7.0 the output changes to this one:

schema {
  query: Queries
}
type Queries {
  one: String
}

I.e. The one query suddenly becomes nullable (even though no changes to the model was made).
Works the same for both Scala 2.13 and 3.3.

@satorg
Copy link
Contributor Author

satorg commented Jun 19, 2024

I believe the culprit is this line:


introduced in #2180

I.e. it forces canFail to true regardless of the underlying Schema and somehow makes the query rendered as nullable even if the corresponsing nullable property is set to false.

If I change canFail to

      override def canFail: Boolean  = ev.canFail

then the model above becomes rendering as is used to be prior to v2.7.0.

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

No branches or pull requests

2 participants