Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 28, 2023
1 parent 2c54f6d commit b39aa54
Show file tree
Hide file tree
Showing 11 changed files with 404 additions and 498 deletions.
36 changes: 20 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,31 +480,34 @@ An example of migrating existing code is given below:
# Existing code
@strawberry.type
class MyDataType:
name: str
name: str


@strawberry.type
class Subscription:
@strawberry.subscription
async def my_data_subscription(
self, info: Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
yield None
async for message in info.context["ws"].channel_listen("my_data", groups=groups):
yield MyDataType(name=message["payload"])
@strawberry.subscription
async def my_data_subscription(
self, info: Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
yield None
async for message in info.context["ws"].channel_listen(
"my_data", groups=groups
):
yield MyDataType(name=message["payload"])
```

```py
# New code
@strawberry.type
class Subscription:
@strawberry.subscription
async def my_data_subscription(
self, info: Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
async with info.context["ws"].listen_to_channel("my_data", groups=groups) as cm:
yield None
async for message in cm:
yield MyDataType(name=message["payload"])
@strawberry.subscription
async def my_data_subscription(
self, info: Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
async with info.context["ws"].listen_to_channel("my_data", groups=groups) as cm:
yield None
async for message in cm:
yield MyDataType(name=message["payload"])
```

Contributed by [Moritz Ulmer](https://github.com/moritz89) via [PR #2856](https://github.com/strawberry-graphql/strawberry/pull/2856/)
Expand Down Expand Up @@ -1123,6 +1126,7 @@ class Point:
x: float
y: float


class GetPointsResult:
circle_points: List[Point]
square_points: List[Point]
Expand Down
2 changes: 2 additions & 0 deletions docs/_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Code blocks now support:
```python highlight=strawberry,str
import strawberry


@strawberry.type
class X:
name: str
Expand All @@ -26,6 +27,7 @@ class X:
```python lines=1-4
import strawberry


@strawberry.type
class X:
name: str
Expand Down
Loading

0 comments on commit b39aa54

Please sign in to comment.