Skip to content

Commit

Permalink
Documenting URL generation
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Jun 21, 2021
1 parent b8315d4 commit 47769e9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
19 changes: 18 additions & 1 deletion vuepress/docs/docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ And enable it in your `build.sbt` file:
enablePlugins(CalibanPlugin)
```

### File generation

At this point, the `caliban` command will cause any files in `src/main/graphql` to be translated into a Caliban-generated client library. This happens automatically any time you `compile`.

By default, all clients are generated with the same client name as the source file, in the `caliban` top-level package.
Expand All @@ -57,15 +59,30 @@ In order to supply more configuration options to the code generator, you can use
)
```

### URL generation

The `calibanSetting` function also permits generating clients for supplied `url`'s:
```scala
Compile / caliban / calibanSettings += calibanSetting(url("http://my-example-service/graphql"))(
cs =>
cs.clientName("ExampleServiceClient")
.packageName("com.example.graphql.client")
)
```

### `calibanSetting` config parameters

The settings available on the `cs` (`CalibanSettings`) builder are:
```
def scalafmtPath(path: String): CalibanSettings
def headers(pairs: (String,String)*): CalibanSettings
def packageName(name: String): CalibanSettings
def genView(value: Boolean): CalibanSettings
def effect(tpe: String): CalibanSettings
def scalarMapping(mapping: (String,String)*): CalibanSettings
def imports(values: String*): CalibanSettings
// Only defined for `url` settings, for use in supplying extra headers when fetching the schema itself
def headers(pairs: (String,String)*): CalibanSettings
```

### `calibanGenClient`
Expand Down
20 changes: 18 additions & 2 deletions vuepress/docs/docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ And enable it in your `build.sbt` file:
enablePlugins(CalibanPlugin)
```

### File generation

At this point, the `caliban` command will cause any files in `src/main/graphql` to be translated into a Caliban-generated client library. This happens automatically any time you `compile`.

By default, all clients are generated with the same client name as the source file, in the `caliban` top-level package.
Expand All @@ -252,17 +254,31 @@ In order to supply more configuration options to the code generator, you can use
)
```

### URL generation

The `calibanSetting` function also permits generating clients for supplied `url`'s:
```scala
Compile / caliban / calibanSettings += calibanSetting(url("http://my-example-service/graphql"))(
cs =>
cs.clientName("ExampleServiceClient")
.packageName("com.example.graphql.client")
)
```

### `calibanSetting` config parameters

The settings available on the `cs` (`CalibanSettings`) builder are:
```
def scalafmtPath(path: String): CalibanSettings
def headers(pairs: (String,String)*): CalibanSettings
def packageName(name: String): CalibanSettings
def genView(value: Boolean): CalibanSettings
def effect(tpe: String): CalibanSettings
def scalarMapping(mapping: (String,String)*): CalibanSettings
def imports(values: String*): CalibanSettings
```
// Only defined for `url` settings, for use in supplying extra headers when fetching the schema itself
def headers(pairs: (String,String)*): CalibanSettings
```

## Building Schemas by hand

Expand Down

0 comments on commit 47769e9

Please sign in to comment.