Skip to content

Commit

Permalink
Add documentation around abstractEffectType option
Browse files Browse the repository at this point in the history
Add to documentation in schema.md around usage of the
--abstractEffectType option.
  • Loading branch information
LaurenceWarne committed Jul 7, 2021
1 parent 94514c3 commit 5a0e2aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions codegen-sbt/src/main/scala/caliban/codegen/CalibanCli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object CalibanCli {

private val genSchemaHelpMsg =
s"""
|calibanGenSchema schemaPath outputPath [--scalafmtPath path] [--headers name:value,name2:value2] [--packageName name] [--effect fqdn.Effect] [--abstractEffectType]
|calibanGenSchema schemaPath outputPath [--scalafmtPath path] [--headers name:value,name2:value2] [--packageName name] [--effect fqdn.Effect] [--abstractEffectType true|false]
|
|This command will create a Scala file in `outputPath` containing all the types
|defined in the provided GraphQL schema defined at `schemaPath`. Instead of a path,
Expand All @@ -63,7 +63,8 @@ object CalibanCli {
|This can be overridden by providing an alternative effect with the `--effect` option.
|The --abstractEffectType flag can also be used to indicate that the effect
|type is abstract, so that it will be added as a type parameter to the generated
|Query and Mutation classes (if applicable).
|Query and Mutation classes (if applicable). In such cases `F` will be used by
|as the type parameter unless the `--effect` option is explicitly given.
|""".stripMargin

private val genClientHelpMsg =
Expand Down
4 changes: 3 additions & 1 deletion vuepress/docs/docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ enablePlugins(CalibanPlugin)

Then call the `calibanGenSchema` sbt command.
```scala
calibanGenSchema schemaPath outputPath [--scalafmtPath path] [--headers name:value,name2:value2] [--packageName name] [--effect fqdn.Effect] [--scalarMappings gqlType:f.q.d.n.Type,gqlType2:f.q.d.n.Type2] [--imports a.b.c._,c.d.E]
calibanGenSchema schemaPath outputPath [--scalafmtPath path] [--headers name:value,name2:value2] [--packageName name] [--effect fqdn.Effect] [--scalarMappings gqlType:f.q.d.n.Type,gqlType2:f.q.d.n.Type2] [--imports a.b.c._,c.d.E] [--abstractEffectType true|false]

calibanGenSchema project/schema.graphql src/main/MyAPI.scala
```
Expand All @@ -246,6 +246,8 @@ The package of the generated code is derived from the folder of `outputPath`. Th

By default, each Query and Mutation will be wrapped into a `zio.UIO` effect. This can be overridden by providing an alternative effect with the `--effect` option.

You can also indicate that the effect type is abstract via `--abstractEffectType true`, in which case `Query` will be replaced by `Query[F[_]]` and so on (note `F` will be used unless `--effect <effect>` is explicitly given in which case `<effect>` would be used in place of `F`).

If you want to force a mapping between a GraphQL type and a Scala class (such as scalars), you can use the
`--scalarMappings` option. Also you can add additional imports by providing `--imports` option.

Expand Down

0 comments on commit 5a0e2aa

Please sign in to comment.