Skip to content

Commit

Permalink
Add example of derives with an env
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdogpr committed Jul 3, 2024
1 parent 0d7e3d3 commit 03369af
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vuepress/docs/docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 03369af

Please sign in to comment.