Bot releases are visible (Hide)
This release includes support for subscriptions over Server-Sent Events, as well as a few bug fixes and improvements.
application/graphql-response+json
#2144 by @ghostdogprMixed
query execution mode, where top-level fields are guaranteed to be executed in parallel and nested fields are executed in batched mode #2129 by @kyri-petrou@lazy
directive and the ZIO environment is not Any
#2125 by @develeonPublished by ghostdogpr 8 months ago
This release includes a new set of performance improvements as well as some usability improvements, in particular for schema code generation. It is fully backward compatible with 2.5.0.
innerThrowable
type for errors raised in ArgBuilders #2118 by @kyri-petrourender
method in CalibanClientError
that can render extensions #2110 by @harrylaou@newtype
for the schema codegen to map ID
to your own types #2091 by @develeon@GQLDeprecated
annotation for deprecated fields #2107 by @johnspadeAny
#2104 by @develeonimplements
#2116 by @ghostdogprPublished by ghostdogpr 9 months ago
This release brings a bug fix for an issue that was introduced in 2.5.0 and possibly caused duplicated fields in responses when using fragments. It is fully backward compatible with 2.5.0.
Document
serialization friendly-ier #2061 by @kyri-petrouFunctionStep
#2059 by @kyri-petrouInjectEnv
implicit for cats.effect.IO #2062 by @kyri-petrou@lazy
fields with abstract effect #2064 by @johnspadePublished by ghostdogpr 10 months ago
This release brings an incredible amount of performance improvements, some major library upgrades (zio-http, Play) as well as some powerful new derivation abilities such as deriving fields from case class methods.
apply
method to Schema
and ArgBuilder
for convenience #2023 by @kyri-petrouPathValue
type instead of Either[String, Int]
#2048 by @kyri-petrouapi.unsafe.runServer
to run a server immediately in the QuickAdapter
#2050 by @kyri-petrouPublished by ghostdogpr 11 months ago
This version brings a few bug fixes and improvements related to schema derivation on Scala 3.
In addition to that, it contains a new adapter named QuickAdapter
and based on zio-http, that serves 2 purposes:
Offer the best performance among all adapters. This adapter is not using Tapir under the hood to prevent any overhead. We picked zio-http and jsoniter-scala because they gave the best benchmarks results among all our supported adapters and json libraries. The only drawback is that it doesn't include WebSocket support at the moment. If you care about performance above all, use this adapter!
Be super quick and easy to get started. With this adapter you can simply do that to go from your api to a running server:
import caliban._
import caliban.quick._ // adds syntax to `GraphQL`
val api: GraphQL[Any] = ???
api.runServer(
port = 8080,
apiPath = "/api/graphql",
graphiqlPath = Some("/graphiql")
)
QuickAdapter
(see above) #1998 by @kyri-petrouPublished by ghostdogpr 12 months ago
This version brings a few bug fixes as well as some performance improvements.
Big thanks to @kyri-petrou for his many contributions!
@defer
fields not working as expected when backed by DataSources #1981 by @kyri-petrouPublished by ghostdogpr almost 1 year ago
This version fixes a regression introduced in 2.4.0 that prevents the usage of java.time
types in schemas when using Scala 3 and JDK 17+ (https://github.com/ghostdogpr/caliban/pull/1950).
Published by ghostdogpr about 1 year ago
This version contains:
[!WARNING]
Due to an issue inzio-http 3.0.0-RC2
, servers exposing websocket endpoints via thecaliban-zio-http
module are required to include additional config for subscriptions to work as shown in this example.This is a temporary workaround until a new version of
zio-http
is released which contains a fix to this issue.
die
errors happening inside the DataSource
#1916 by @ghostdogprmocking up superclass for module class macros
warning on Scala 3 #1880 by @kyri-petrourender
on a schema #1888 by @nox213CalibanError
(not that getCause
will return null
in ValidationError
) #1924 by @kyri-petrou@lazy
directive to generate side-effecting fields in server code generation #1927 by @oyvindbergPublished by ghostdogpr about 1 year ago
This version contains important performance improvements as well as support for Pekko.
VariableCoercer
#1856 by @kyri-petrourenderSchema
to render a schema without a resolver #1877 by @ghostdogprPublished by ghostdogpr about 1 year ago
This version contains a lot of small fixes as well as performance and usability improvements.
status
label to the graphql_fields_total
metric #1724 by @SvenWvalidateSchema
#1731 by @ghostdogprSemiAuto
#1785 by @kyri-petroufieldWithArgs
schema generation #1812 by @paulpdanielsServerRequest
in configure
#1816 by @ghostdogprisRepeatable
during introspection (disable it if the remote server does not support it) #1732 by @ghostdogprderives Schema.SemiAuto
in schema code generation #1758 by @nox213Published by ghostdogpr over 1 year ago
This is a tiny release with a single change on ZHttpAdapter
(#1723). We noticed that the type signatures of makeHttpService
and makeWebSocketService
were inconsistent (the former returned HttpApp[R, Throwable]
while the latter returned HttpApp[R, Response]
aka App[R]
). We've made them both return App[R]
, which should be easier to use!
Published by ghostdogpr over 1 year ago
This release brings a few important changes, including a refactor of request interceptors, support for the @defer
directive and support for Scala Native in caliban-client 🚀
Love this project? I am now on Github Sponsors. A good way to give back and encourage future developments! ❤️
Request interceptors and configuration options such as skipValidation
or enableIntrospection
have been modified to be more powerful: you can now eliminate part of ZIO environment with request interceptors, and you can modify execution configuration dynamically.
These improvements require a small change in existing code. When calling makeHttpService
, makeHttpUploadService
or makeWebSocketService
, you now need to wrap your interpreter into (respectively) an HttpInterpreter
, HttpUploadInterpreter
or WebSocketInterpreter
.
// before
ZHttpAdapter.makeHttpService(interpreter)
// after
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
With these wrapper classes come 2 powerful methods:
configure
takes a Configurator[R]
which is an alias for URIO[R & Scope, Unit]
.setSkipValidation
, setEnableIntrospection
and setQueryExecution
are available in the Configurator
object and let you dynamically change the configuration of the interpreter.intercept
takes an Interceptor[-R1, +R]
which is an alias for ZLayer[R1 & ServerRequest, TapirResponse, R]
.configure
that gives you access to the incoming request (ServerRequest
) and lets you modify the environment of the interpreter (from R
to R1
). A typical use case would be to extract an authentication token from the request and eliminate the authentication requirement from the environment if the token is valid. See an example here. You can also use this to change the configuration based on the incoming request (e.g. allow introspection only when a valid token is present).val interpreter: GraphQLInterpreter[AuthToken, CalibanError] = ???
// turn our GraphQL interpreter into an HttpInterpreter
val noAuthInterpreter: HttpInterpreter[AuthToken, CalibanError] = HttpInterpreter(interpreter)
// define authentication logic (from a ServerRequest, fail or build an AuthToken)
val auth: ZLayer[ServerRequest, TapirResponse, AuthToken] = ???
// pass our interceptor to eliminate the AuthToken requirement from the environment
val authInterpreter: HttpUploadInterpreter[Any, CalibanError] = httpInterpreter.intercept(auth)
// get our route for Akka Http
val route = AkkaHttpAdapter.makeHttpService(authInterpreter)
This change was done in #1707 by @ghostdogpr
@defer
directive #1480 by @paulpdanielsscalarSchema
#1694 by @yarianderives ArgBuilder.GenAuto
derivation #1699 by @kyri-petrouderives Schema.Auto
derivation #1666 by @kyri-petrouobjectSchema
#1698 by @yarianPublished by ghostdogpr over 1 year ago
This release is packed with features, improvements and fixes. In fact, it is probably the single most important release since Caliban Client was added. It contains several breaking changes, so make to read what follows before upgrading!
One of the most requested features of Caliban was the ability to opt out from the automatic schema derivation and use a semi-automatic approach where you have to create a schema for each individual type. Automatic schema derivation is convenient when you get started, but can quickly becoming a pain when you have large schemas: slow compilation, large amount of generated code, difficulty finding which types require a custom instance or even knowing which instance is actually used.
We decided to make automatic generation optional using an import. Without this import, you will need to provide an implicit/given schema for each type that is not already supported. We also added support for the derives
keyword in Scala 3, so that it's super easy to create schemas with the least amount of boilerplate.
Here is how derivation work with Scala 3:
// semi-auto derivation, needs a Schema for inner types
final case class Foo(value: String) derives Schema.SemiAuto
// semi-auto derivation when R in Schema[R, A] is not Any
object CustomSchema extends SchemaDerivation[MyEnv]
final case class Foo(value: String) derives CustomSchema.SemiAuto
// semi-auto derivation without the derives keyword
given Schema[MyEnv, Foo] = Schema.gen
// auto derivation
import Schema.auto._
given Schema[MyEnv, Foo] = genAll
Here's how it looks with Scala 2 (also cross-compile with Scala 3):
// semi-auto derivation, needs Schema for inner types
implicit val fooSchema: Schema[Any, Foo] = Schema.gen
// auto derivation, generates a Schema for inner types
import Schema.auto._
implicit val fooSchema: Schema[Any, Foo] = genAll
// semi-auto derivation when R in Schema[R, A] is not Any
object schema extends GenericSchema[MyEnv]
implicit val fooSchema: Schema[MyEnv, Foo] = schema.gen
// auto derivation when R in Schema[R, A] is not Any
object schema extends GenericSchema[MyEnv]
import schema.auto._
implicit val fooSchema: Schema[MyEnv, Foo] = genAll
Note that ArgBuilder
derivation follows the same pattern (without the R
part) and requires an import if you want auto generation.
This change was done in #1591 by @ghostdogpr
Historically each adapter was tied to a specific Json library: for example Circe was used for http4s and zio-http, while play-json was the default for play. As we recently introduced support for jsoniter-scala, we found it was quite inconvenient to use it with the existing adapters. So we decided to make the adapters completely free of any Json dependency, so you can use the Json library you want!
All you have to do is adding one of these Tapir dependencies:
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "1.2.11" // Circe
"com.softwaremill.sttp.tapir" %% "tapir-jsoniter-scala" % "1.2.11" // Jsoniter
"com.softwaremill.sttp.tapir" %% "tapir-json-play" % "1.2.11" // Play JSON
"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "1.2.11" // ZIO JSON
And then later in your code (you only need one!):
import sttp.tapir.json.circe._
import sttp.tapir.json.jsoniter._
import sttp.tapir.json.play._
import sttp.tapir.json.zio._
This change was done in #1552 by @kyri-petrou
Performance was improved in almost every parts of Caliban: from parsing to validation to execution. Even Caliban Client received some love! Here are the details:
ZPure
instead of ZIO
for validation logic, which improves validation performance greatly #1633 by @paulpdanielsgraphQL
function directly to the caliban
package (the old one is still there but deprecated) by @ghostdogprWrappers.logSlowQueries
for logging slow queries with ZIO.logWarning
Wrappers.metrics
for gathering metrics about query executionTracingWrapper.traced
for creating traces with OpenTelemetry (in a separate dependency caliban-tracing
)Input
to input objects that already have that suffix #1471 by @brodinSchema
for fields annotated with @GQLExcluded
(Scala 3 only) #1630 by @kyri-petrouApolloPersistedQueries
wrapper) #1557 by @kyri-petrouisIntrospection
field on Document
#1662 by @kyri-petrouSelectionBuilder
public #1596 by @lassebnPublished by ghostdogpr almost 2 years ago
This release contains several bug fixes and dependency upgrades (see versions here), as well as support for the Jsoniter Json library. This library is optimized for performance so the encoding/decoding of GraphQL requests/responses consumes less memory and is significantly faster than other solutions. Note that for performance reasons, this implementation is not tail-recursive so you might want to limit query depth with the maxDepth
wrapper. Give it a try if you're looking for the best possible throughput!
RequestInterceptor.empty
a val
, so that we don't instantiate many of them #1435 by @guizmaiiString
is returned by introspection even when it's not used #1444 by @ghostdogprVARIABLE_DEFINITION
as a possible directive location #1446 by @aadunnRootType
#1508 by @frekwWebSocket.afterInit
#1515 by @ghostdogpr_
#1540 by @guymersPublished by ghostdogpr about 2 years ago
Schema
for java.time
on JDK 17 #1414 by @ghostdogprskipValidation
is true #1421 by @ghostdogprPublished by ghostdogpr about 2 years ago
Schema
for java.time
on JDK 17 #1414 by @ghostdogprskipValidation
is true #1421 by @ghostdogprPublished by ghostdogpr over 2 years ago
This release contains the same features as 1.4.2, but is based on ZIO 2.0.0. You can consult this guide about the upgrade and the differences between ZIO 1.x and 2.x.
Going forward, all new features will be made on this branch. We might backport important bug fixes to the 1.x branch if necessary.
Published by ghostdogpr over 2 years ago
graphql-transport-ws
WebSocket protocol #1354 by @paulpdanielsOption
in the generated code #1377 by @alterationx10Published by ghostdogpr over 2 years ago
ApolloPersistedQuery
wrapper #1362 by @paulpdanielstargets
to field metadata to expose the type conditions of a field #1315 by @frekwPublished by ghostdogpr over 2 years ago
This release contains the same changes as 1.4.0, but for ZIO 2.0. It is based on ZIO 2.0.0-RC2.