Broken backward compatibility in CatsInterop since v2.7.0
satorg opened this issue · comments
Sergey Torgashov commented
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.
Sergey Torgashov commented
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.