Skip to content

Commit

Permalink
feat(graphql): allow to change max_query_depth and max_query_complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriau committed Dec 10, 2024
1 parent eb9bb47 commit 546c1c5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ api_platform:

# The nesting separator used in the filter names.
nesting_separator: _


# The maximum query depth. Look at http://webonyx.github.io/graphql-php/security/#limiting-query-depth
max_query_depth: 100

# The maximum query complexity. Look at http://webonyx.github.io/graphql-php/security/#query-complexity-analysis
max_query_complexity: 1000

collection:
pagination:
enabled: true
Expand Down
32 changes: 32 additions & 0 deletions core/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,38 @@ return [
];
```

## Change Max Query Depth

For security reason, the max query depth should be limited to avoid deep queries. It's set to 100 by default.

### Symfony config to change the Max Query Depth

If you need to change it, it can be done in the configuration:

```yaml
# api/config/packages/api_platform.yaml
api_platform:
graphql:
max_query_depth: 7
# ...
```

## Change Max Query Complexity

For security reason, the max query complexity should be limited to avoid complex queries. It's set to 100 by default.

### Symfony config to change the Max Query Complexity

If you need to change it, it can be done in the configuration:

```yaml
# api/config/packages/api_platform.yaml
api_platform:
graphql:
max_query_complexity: 50
# ...
```

## Request with `application/graphql` Content-Type

If you wish to send a [POST request using the `application/graphql` Content-Type](https://graphql.org/learn/serving-over-http/#post-request),
Expand Down

0 comments on commit 546c1c5

Please sign in to comment.