Skip to content

Releases: ghostdogpr/caliban

v1.3.2

07 Jan 11:22
b1764be
Compare
Choose a tag to compare

Release Notes

This release fixes a few bugs.

Server

Tools

v1.3.1

15 Dec 04:55
a1ca35b
Compare
Choose a tag to compare

Release Notes

This release fixes a few bugs and brings some goodies.

Server

  • Fixed fields merging logic and improve overall performance #1199 by @ghostdogpr
  • Fixed tapir-based subscriptions (stop commands were not properly handled) #1205 by @ghostdogpr
  • Fixed behavior when no value has been provided for a variable (keep it empty instead of making it null) #1195 by @guymers
  • Added cost estimation wrappers #1180 by @paulpdaniels
  • Added helpers and a full-fledged example for using Http4sAdapter with F[_] and cats-effect #1206 by @ghostdogpr
  • Changed RequestInterceptor to be same as the old ContextWrapper, making it possible to wrap the effect and change the ZIO environment #1208 by @ghostdogpr

Tools

v1.3.0

26 Nov 06:48
Compare
Choose a tag to compare

Release Notes

This release brings two important changes to Caliban:

  • the server adapters have been completely rewritten using Tapir
  • the Schema.gen function has been changed to make it easier to deal with ZIO environment, especially with Scala 3

New adapters based on Tapir

Adapters have been completely rewritten and are now sharing code thanks to Tapir, with the following benefits:

  • features are now consistent between each of the adapters: upload support, request interceptors, websocket hooks...
  • you can create your own adapter very easily for any library that Tapir supports
  • you can use the Json library of your choice easily
  • tapir endpoints can be used to generate an sttp client (our test suite takes advantage of that)

Notable changes:

  • FinchAdapter has been removed
  • PlayRouter has been removed, in favor of PlayAdapter which is consistent with the other adapters
  • AkkaHttpAdapter json support is now done via tapir
  • Http4sAdapter requires Clock with Blocking in the environment (this constraint comes from the tapir interpreter)
  • ContextWrapper is now RequestInterceptor
  • Callbacks is now WebSocketHooks

Look at the documentation for more info. Examples have been updated and migration shouldn't be difficult, but feel free to drop by Discord if you need any help.

Change done in #1125 by @ghostdogpr

New gen function

TL;DR
gen[A] becomes gen[R, A]

For Scala 2:
You no longer need to worry about calling the right gen (from Schema vs GenericSchema), you can simply use Schema.gen everywhere. It now takes 2 type parameters R and A but you can usually omit them if you explicitly define the return type of your schema.

object schema extends GenericSchema[MyEnv]
import schema._

implicit val queriesSchema: Schema[MyEnv, Queries] = Schema.gen
// or
implicit val queriesSchema = Schema.gen[MyEnv, Queries]

If you use genMacro, you still need to do it on GenericSchema.

For Scala 3:
It is no longer necessary to use GenericSchema[R]. You can simply use Schema.gen when you need to explicitly derive a schema. Caliban will be able to derive a Schema[R, A] directly from that.

If your R is not Any, you need to pass it to the graphQL function, unless you already have a Schema[R, Query] in scope:

val api = graphQL[MyEnv, Queries, Unit, Unit](RootResolver(queries))
// or
implicit val queriesSchema: Schema[MyEnv, Queries] = Schema.gen
val api = graphQL(RootResolver(queries))

If you want to see the code generated by the derivation, you can use Schema.genDebug instead. It will print the generated code to the console when compiling.

Change done in #1115 by @ghostdogpr

Other Changes

Server

Client

  • Code generation for interfaces was modified #1103 #1169 by @AlixBa. For each interface, 3 functions will be generated:
    • one with no suffix that takes a SelectionBuilder for each member implementing the interface
    • one suffixed with Option that takes an optional SelectionBuilder for each member implementing the interface, with default to None. That allows you not specifying a selection for every possible member.
    • one suffixed with Interface that takes a SelectionBuilder of the interface itself. This is useful if you want to select the common fields without having to provide a selection for each member.

Tools

v1.2.4

17 Nov 10:36
3086e20
Compare
Choose a tag to compare

Release Notes

This is a minor release to fix small bugs and add minor things.

Server

  • Fixed int values coercion into float values (it was making false positive validation errors) #1150 by @ghostdogpr
  • Added support for a @GQLExcluded annotation that can hide fields #1141 by @frekw

Tools

  • Fixed the code generation to support fields starting with capital letters #1140 by @several27
  • Changed schema comparison to consider the addition of a mandatory argument breaking #1147 by @ghostdogpr
  • Added Scala 3 reserved keywords support in code generation #1145 by @jgoday

v1.2.3

12 Nov 05:02
93aa19f
Compare
Choose a tag to compare

Release Notes

This is a minor release to fix some small bugs introduced by the new validations.

Server

v1.2.2

05 Nov 07:21
Compare
Choose a tag to compare

Release Notes

Since I started Caliban 2 years ago, there were 3 validation rules that I left aside because they were pretty tricky to implement. Motivated by @frekw who bravely tackled the hardest one, I've implemented the last 2 and Caliban is now 100% compliant with the GraphQL spec! 🎉

If you had invalid queries that were accepted in the past, they might be rejected now so make sure to test before you upgrade Caliban straight to production 😉

Server

Adapters

  • Removed blaze dependency from the http4s module #1110 by @kubukoz
  • Extended request wrapper support to websockets in the Play Adapter #1063 by @easel
  • Fixed variable parsing from query params in the ZIO HTTP Adapter #1118 by @ghostdogpr
  • Fixed UTF-8 handling for request bodies in the ZIO HTTP Adapter #1120 by @frekw
  • Fixed application/graphql handling in the ZIO HTTP Adapter #1124 by @frekw

Client

  • Added a new generated function for union types that allows to not specify a selection for every subtype of the union #1099 by @ghostdogpr based on earlier work from @anotherhale

Tools

  • Fixed the package name extraction regex used during code generation #1116 by @pavlosgi

v1.2.1

14 Oct 03:15
2839fd2
Compare
Choose a tag to compare

Release Notes

Adapters

  • Made the signature of makeWebSocketService in the Http4s adapter more permissive, allowing you to use a different R between GraphQLInterpreter and WebSocketBuilder2 #1080 by @ghostdogpr

Client

Tools

  • Added an option ctCalibanClientsVersionedCode to the compile time codegen plugin, so that it generates code in the target folder #1087 by @guizmaii
  • Made all the generated case classes final #1081 by @guizmaii

v1.2.0

10 Oct 02:05
Compare
Choose a tag to compare

Release Notes

The highlight of this release is the addition of a new sbt plugin to generate your Caliban client code directly from your Caliban server code at compile time. This is useful if you use Caliban on both client and server side. Check the plugin documentation for more details.

Here's a little preview showing how you tell sbt where your GraphQL server API is defined:

lazy val api =
  project
    .enablePlugins(CompileTimeCalibanServerPlugin)
    .settings(
      Compile / ctCalibanServer / ctCalibanServerSettings :=
        Seq(
          "com.example.my.awesome.project.api.CalibanServer.graphqlApi" -> ClientGenerationSettings.default
        )
    )

It is still very new, so let us know if you encounter any bug. This sbt voodoo magic was brought in #1037 by @guizmaii 🙏

Server

  • Added support for @GQLDefault annotation for defining the default value of a field #1043 by @frekw
  • Added Schema and ArgBuilder instances for Short #1011 by @Fluxx
  • Added helpers for creating Schema instances for non-Throwable errors, see customErrorEffectSchema, customErrorQuerySchema and customErrorStreamSchema #1059 by @ghostdogpr
  • Fixed fragment spreads parsing in Scala 3 #1066 by @ghostdogpr
  • Fixed field metadata for enums coming from JSON variables (they now return EnumValue instead of StringValue) #1064 by @frekw

Adapters

  • Upgraded http4s to 0.23.5. This caused a change in the interface of makeWebSocketService, because WebSocketBuilder was deprecated by http4s. It now requires a WebSocketBuilder2. See the examples project for an updated usage. #1075 by @ghostdogpr
  • Added WebSocket lifecycle hooks to the zio-http adapter #1013 by @frekw

Tools

  • Added a new sbt plugin to generate client code from server code #1037 by @guizmaii (see above)
  • Fixed deprecated behaviour in SchemaLoader.fromCaliban #1006 by @ghostdogpr
  • Fixed LocationInfo json decoding #1015 by @frekw
  • Fixed interface types resolution in RemoteSchema #1018 by @frekw
  • Added GraphQL error extensions decoding #1038 by @frekw
  • Added then to the list of reserved keywords #1032 by @RhnSharma
  • Added SchemaLoader.fromDocument #1036 by @frekw

v1.1.1

08 Aug 02:04
1add287
Compare
Choose a tag to compare

Release Notes

Server

  • Allowed tagless final variants for Http4sAdapter using R instead of Any for the environment #972 by @ghostdogpr
  • Upgraded cats-effect and http4s to 3.2.1 and 0.23 respectively (CE3-based). The Finch and Monix interop is still using CE2. The http4s adapter is also published for Scala 3 now. #891 by @iRevive
  • Added a new annotation @GQLValueType that allows redirecting a union type member to a different type defined in another file (removing the "sealed" constraint for unions) #989 by @paulpdaniels
  • Added Scala 3 support for the federation module #997 by @ghostdogpr

Tools

  • Added an option to client code generation to generate code in multiple files instead of a single one. Also allowed disabling formatting during code generation. #964 by @alexdupre
  • Added an option to client code generation to map unknown enum values to __Unknown instead of failing #976 by @rtimush
  • Made the client code generation automatically regenerate code when configs change #959 by @blast-hardcheese
  • Made the client code generation properly detect packages when using a Play Framework project #956 by @yonlugoh

v1.1.0

08 Jul 00:37
Compare
Choose a tag to compare

Release Notes

The main change in this release is the ability to run caliban client code generation automatically when you compile, instead of the previous (but still supported) manual sbt command. CodegenPlugin was also renamed to CalibanPlugin (the old name still exists but is deprecated).

See the updated documentation for more information. This work was done in #933 by @blast-hardcheese.

Server

  • Fixed backslash parsing in queries #943 by @mingyuchi
  • Added support for upload in the Http4s Adapter (batching not supported yet, like with Play) #945 by @pomadchin
  • Added support for GQLInterface and GQLUnion annotations on enum-like traits #941 by @rtimush
  • Added the ability to distinguish between a field value of null and a missing field in ArgBuilders #929 by @stephendavidmarsh
  • Added a new resolver type to support using Field metadata with federation #939 by @paulpdaniels

Client

  • Fixed string escaping problem when encoding arguments #942 by @mingyuchi
  • Added a value helper function for enumeration members in generated code #936 by @blast-hardcheese
  • Added a values helper function on enumerations in generated code, to get the list of possible members #934 by @blast-hardcheese

Tools

  • Fixed wrong behavior in server codegen when a type is used in multiple unions #948 by @AlixBa
  • Allowed scalarMappings to be used with enumerations in client codegen #930 by @blast-hardcheese
  • Allowed colons in header values in client codegen --headers option #938 by @ghostdogpr
  • Added a new parameter --abstractEffectType to server codegen to generate code with F[_] #951 by @LaurenceWarne