From 03369afb5a2e4dcac367afde80222fe04fc14b19 Mon Sep 17 00:00:00 2001 From: Pierre Ricadat Date: Wed, 3 Jul 2024 17:21:45 +0900 Subject: [PATCH] Add example of derives with an env --- vuepress/docs/docs/schema.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vuepress/docs/docs/schema.md b/vuepress/docs/docs/schema.md index c67440b25..21b8d2a9e 100644 --- a/vuepress/docs/docs/schema.md +++ b/vuepress/docs/docs/schema.md @@ -537,6 +537,13 @@ val api = graphQL[MyEnv, Queries, Unit, Unit](RootResolver(queries)) // val api = graphQL(RootResolver(queries)) // it will infer MyEnv thanks to the instance above ``` +When using the `derives` syntax in Scala 3, you need to create an object extending `caliban.schema.SchemaDerivation[R]` and use the `SemiAuto` method to generate the schema. +```scala +object customSchema extends SchemaDerivation[MyEnv] +case class Queries(characters: Task[List[Character]], + character: CharacterName => RIO[Console, Character]) derives customSchema.SemiAuto +``` + ## Subscriptions All the fields of the subscription root case class MUST return `ZStream` or `? => ZStream` objects.