Skip to content

Commit

Permalink
Release 🍓 0.178.0
Browse files Browse the repository at this point in the history
  • Loading branch information
botberry committed May 22, 2023
1 parent c2d50c0 commit 4519c39
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 67 deletions.
71 changes: 71 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,77 @@
CHANGELOG
=========

0.178.0 - 2023-05-22
--------------------

This release introduces the new `should_ignore` argument to the `QueryDepthLimiter` extension that provides
a more general and more verbose way of specifying the rules by which a query's depth should be limited.

The `should_ignore` argument should be a function that accepts a single argument of type `IgnoreContext`.
The `IgnoreContext` class has the following attributes:
- `field_name` of type `str`: the name of the field to be compared against
- `field_args` of type `strawberry.extensions.query_depth_limiter.FieldArgumentsType`: the arguments of the field to be compared against
- `query` of type `graphql.language.Node`: the query string
- `context` of type `graphql.validation.ValidationContext`: the context passed to the query
and returns `True` if the field should be ignored and `False` otherwise.
This argument is injected, regardless of name, by the `QueryDepthLimiter` class and should not be passed by the user.

Instead, the user should write business logic to determine whether a field should be ignored or not by
the attributes of the `IgnoreContext` class.

For example, the following query:
```python
"""
query {
matt: user(name: "matt") {
email
}
andy: user(name: "andy") {
email
address {
city
}
pets {
name
owner {
name
}
}
}
}
"""
```
can have its depth limited by the following `should_ignore`:
```python
from strawberry.extensions import IgnoreContext


def should_ignore(ignore: IgnoreContext):
return ignore.field_args.get("name") == "matt"


query_depth_limiter = QueryDepthLimiter(should_ignore=should_ignore)
```
so that it *effectively* becomes:
```python
"""
query {
andy: user(name: "andy") {
email
pets {
name
owner {
name
}
}
}
}
"""
```

Contributed by [Tommy Smith](https://github.com/tsmith023) via [PR #2505](https://github.com/strawberry-graphql/strawberry/pull/2505/)


0.177.3 - 2023-05-19
--------------------

Expand Down
66 changes: 0 additions & 66 deletions RELEASE.md

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "strawberry-graphql"
packages = [ { include = "strawberry" } ]
version = "0.177.3"
version = "0.178.0"
description = "A library for creating GraphQL APIs"
authors = ["Patrick Arminio <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 4519c39

Please sign in to comment.