Skip to content

Commit b7ed3e8

Browse files
docs: shorten the release description
1 parent 09fe07f commit b7ed3e8

1 file changed

Lines changed: 4 additions & 30 deletions

File tree

RELEASE.md

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,8 @@ release type: minor
44

55
Adjust the optimizer to handle when the same field is selected multiple times via aliases with different arguments and the field doesn't have a custom resolver.
66

7-
Also add support for aliasing custom fields with `annotate`/`prefetch_related` optimizer hint callables, together with three new public helpers:
7+
Also add support for aliasing custom fields with `annotate`/`prefetch_related` optimizer hint callables, together with three new public helpers (see the [optimizer guide](https://strawberry-graphql.github.io/strawberry-django/guide/optimizer/) for examples):
88

9-
- `optimizer_hint_key(info)`: returns a unique, deterministic attribute name for the current field selection (based on the response key, i.e. the alias). It returns the same value inside an optimizer hint callable and inside the field's resolver, so it can be used to name a `Prefetch(to_attr=...)` in the hint and read the value back in the resolver.
10-
- `get_hint_value(source, info, default_attr=None, *, default=...)`: reads the value produced by an optimizer hint for the current selection, checking the alias-scoped attribute/label first and falling back to `default_attr`/`default`. Dict-form annotations with multiple callable labels are supported, so a resolver can combine several per-alias annotated values.
11-
- `get_field_arguments(info)`: resolves the argument values of the current field selection (including variables), usable both inside hint callables and resolvers.
12-
13-
Example:
14-
15-
```python
16-
@strawberry_django.type(Milestone)
17-
class MilestoneType:
18-
@strawberry_django.field(
19-
annotate=lambda info: Count(
20-
"issue",
21-
filter=Q(issue__name__contains=get_field_arguments(info)["nameContains"]),
22-
),
23-
)
24-
def issues_count_filtered(self, root, info, name_contains: str) -> int:
25-
return get_hint_value(root, info, "issues_count_filtered")
26-
```
27-
28-
```graphql
29-
{
30-
milestoneList {
31-
foo: issuesCountFiltered(nameContains: "foo")
32-
bar: issuesCountFiltered(nameContains: "bar")
33-
}
34-
}
35-
```
36-
37-
Each alias resolves the hint callable with its own scoped `info`, and callable annotations are stored under an alias-scoped label so they don't clash with each other.
9+
- `optimizer_hint_key(info)`: a unique, deterministic attribute name for the current field selection (based on the alias), stable between the hint callable and the resolver.
10+
- `get_hint_value(source, info, default_attr=None, *, default=...)`: reads the value produced by an optimizer hint for the current selection.
11+
- `get_field_arguments(info)`: resolves the argument values of the current field selection (including variables), usable in both hint callables and resolvers.

0 commit comments

Comments
 (0)