Releases: ghostdogpr/caliban
v1.3.2
Release Notes
This release fixes a few bugs.
Server
- Fixed selection merging with conflicting fragments #1213 by @ghostdogpr
- Fixed rendering of empty field list #1220 by @Fluxx
- Removed useless
Has
constraint in ZHttpAdapter #1241 by @ghostdogpr
Tools
- Made compile time codegen plugin work with sbt 1.6.x #1236 by @ghostdogpr
- Fixed interface/union client code generation #1217 #1223 #1237 by @ghostdogpr @iRevive
- Escaped function name properly in interface client generation #1225 by @ghostdogpr
v1.3.1
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
withF[_]
and cats-effect #1206 by @ghostdogpr - Changed
RequestInterceptor
to be same as the oldContextWrapper
, making it possible to wrap the effect and change the ZIO environment #1208 by @ghostdogpr
Tools
- Added a new option to schema generation for preserving input names #1186 by @LaurenceWarne
v1.3.0
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 removedPlayRouter
has been removed, in favor ofPlayAdapter
which is consistent with the other adaptersAkkaHttpAdapter
json support is now done via tapirHttp4sAdapter
requiresClock with Blocking
in the environment (this constraint comes from the tapir interpreter)ContextWrapper
is nowRequestInterceptor
Callbacks
is nowWebSocketHooks
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
- A new spec for GraphQL was released in October 2021. Support for some new features have been added:
- custom scalar specification URLs #1171 by @ghostdogpr
__typename
is not valid at subscription root #1163 by @ghostdogpr
- Fixed
withAdditionalTypes
behavior #1170 #1175 #1176 #1177 by @frekw @ghostdogpr - Fixed upload support when dealing with nested fields #1167 by @frekw
- Fixed deprecated directive support on manually created fields #1168 by @frekw
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 optionalSelectionBuilder
for each member implementing the interface, with default toNone
. That allows you not specifying a selection for every possible member. - one suffixed with
Interface
that takes aSelectionBuilder
of the interface itself. This is useful if you want to select the common fields without having to provide a selection for each member.
- one with no suffix that takes a
Tools
- Made the source generator plugin support server-side code generation #1137 #1155 by @nikodemin @kubukoz
- Added support for multiple setting sets per file in
CalibanPlugin
#1156 by @kubukoz - Added
calibanVersion
setting toCalibanPlugin
#1165 by @kubukoz - Updated scalafmt and stopped using deprecated methods #1174 by @AlixBa
v1.2.4
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
Release Notes
This is a minor release to fix some small bugs introduced by the new validations.
Server
- Fixed validation of null inputs in variables #1133 by @darl
- Fixed GQL syntax strings incorrectly validated as enums #1134 by @frekw
- Fixed translation of input value strings to enums #1136 by @frekw
- Introduced
GraphQLAspect
to customize aGraphQL
object. See the documentation. #1128 by @paulpdaniels
v1.2.2
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
- Implemented "Field Selection Merging" validation #1084 by @frekw
- Implemented "All Variable Usages are Allowed" validation #1092 by @ghostdogpr
- Implemented "Values of Correct Type" validation #1093 by @ghostdogpr
- Added a new parameter
isScalar
to the@GQLValueType
annotation to generate a scalar #1127 by @ghostdogpr - Fixed a few mistakes in validation #1090 #1101 #1112 by @frekw
- Fixed
LocationInfo
Play Json serializer #1096 by @ghostdogpr
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
v1.2.1
Release Notes
Adapters
- Made the signature of
makeWebSocketService
in the Http4s adapter more permissive, allowing you to use a different R betweenGraphQLInterpreter
andWebSocketBuilder2
#1080 by @ghostdogpr
Client
- Improved error handling in the laminext module #1086 by @ghostdogpr
Tools
v1.2.0
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
andArgBuilder
instances forShort
#1011 by @Fluxx - Added helpers for creating
Schema
instances for non-Throwable errors, seecustomErrorEffectSchema
,customErrorQuerySchema
andcustomErrorStreamSchema
#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 ofStringValue
) #1064 by @frekw
Adapters
- Upgraded http4s to 0.23.5. This caused a change in the interface of
makeWebSocketService
, becauseWebSocketBuilder
was deprecated by http4s. It now requires aWebSocketBuilder2
. 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 inSchemaLoader.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
Release Notes
Server
- Allowed tagless final variants for
Http4sAdapter
usingR
instead ofAny
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
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
andGQLUnion
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 withF[_]
#951 by @LaurenceWarne