github ghostdogpr/caliban v2.8.0

3 days ago

This release brings a long-awaited feature: @oneOf inputs, based on this RFC which is almost finalized and already implemented in several libraries in other languages. This allows you to use ADTs as input parameters:

@GQLOneOfInput
enum Foo {
  case FooString(stringValue: String)
  case FooInt(intValue: Int)
}
case class FooArgs(input: Foo)
case class Queries(foo: FooArgs => String)

This will generate the following schema, and the validation will verify that only one of those fields is provided in incoming queries.

input FooInput @oneOf {
  stringValue: String
  intValue: Int
}

type Queries {
  foo(input: FooInput!): String!
}

This release also includes a few breaking changes that should impact a very low amount of users, but here they are just in case:

  • Removed code that was deprecated for a long time
  • Removed unnecessary type parameter on Validator.prepare
  • Removed convertHttpStreamingEndpoint/convertHttpEndpointToFuture
  • Migrated the (deprecated) zio-http adapter to use the (recommended) quick adapter, which changes the syntax a bit (you have to pass the interpreter and config directly to the method rather than using the HttpInterpreter / WebSocketInterpreter). If you had RequestInterceptor before, you can use zio-http Middleware instead.
  • Removed the dependency on zio-prelude, so if you relied on Caliban for the transitive dependency, you will have to depend on it explicitly.
  • Some methods (such as GraphQL#interpreter) that returned a ZIO now return an Exit, which is a subtype of ZIO that you can convert to an Either or Option without needing to run the ZIO

New features

  • Added support for @oneOf inputs for both server and client by @kyri-petrou in #1846 #2294
  • Made it easier to use tapir with impure effects such as Ox by @ghostdogpr in #2282
  • Added an Scala3-only annotation to derive all case class methods as graphql fields by @kyri-petrou in #2306
  • Added a transformer that excludes fields / inputs based on directives by @kyri-petrou in #2293

Bug fixes

  • Fixed codegen path on Windows by @OlegYch in #2304
  • Fixed derivation of case objects / parameterless case classes that contain @GQLField methods by @kyri-petrou in #2305

Performance improvements

Code cleanup

Don't miss a new caliban release

NewReleases is sending notifications on new releases.