Skip to content

Commit

Permalink
feat(max-batch): Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebruijn committed Jan 19, 2024
1 parent 9d06f0f commit 39a78fe
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ _This is repository inspired by the great work of the similarly named Javascript
* [Max Aliases](docs/max_aliases.md)
* [Max Tokens](docs/max_tokens.md)
* [Max Depth](docs/max_depth.md)
* [Max Batch](docs/max_batch.md)
* [Enforce POST](docs/enforce_post.md)
* _Max Directives (coming soon)_
* _Cost Limit (coming soon)_
Expand Down
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Please see each section for in-depth documentation
* [Block Field Suggestions](block_field_suggestions.md)
* [Max Aliases](max_aliases.md)
* [Max Tokens](max_tokens.md)
* [Enforce POST](enforce_post)
* [Enforce POST](enforce_post.md)
* [Max Batch](max_batch.md)
8 changes: 8 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ max_tokens:
# Reject the request when the rule fails. Disable this to allow the request regardless of token count.
reject_on_failure: true

max_batch:
# Enable the feature
enable: "true"
# The maximum number of operations within a single batched request.
max: 5
# Reject the request when the rule fails. Disable this to allow the request regardless of token count.
reject_on_failure: "true"

disable_get_method:
# Enable the feature
enable: "true"
Expand Down
37 changes: 37 additions & 0 deletions docs/max_batch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Max Batch

Restricts the maximum number of operations inside a batched request. This helps prevent an excessive number operations reaching your landscape through minimal requests.
This can be useful to prevent DDoS attacks, Heap Overflows or Server overload.

<!-- TOC -->

## Configuration

You can configure `go-graphql-armor` to limit the maximum number of operations allowed inside a batch request.

```yaml
max_batch:
# Enable the feature
enable: "true"
# The maximum number of operations within a single batched request.
max: 5
# Reject the request when the rule fails. Disable this to allow the request regardless of token count.
reject_on_failure: "true"
```
## Metrics
This rule produces metrics to help you gain insights into the behavior of the rule.
```
go_graphql_armor_max_batch_results{result}
```


| `result` | Description |
|---------|--------------------------------------------------------------------------------------------------------------|
| `allowed` | The rule condition succeeded |
| `rejected` | The rule condition failed and the request was rejected |
| `failed` | The rule condition failed but the request was not rejected. This happens when `reject_on_failure` is `false` |

No metrics are produced when the rule is disabled.

0 comments on commit 39a78fe

Please sign in to comment.