Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to run subscriptions code snippet as it is #1296

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/operations/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ async def test_mutaton():
And finally, a test for our [`count` Subscription](docs/general/subscriptions.md):

```python
import asyncio
import pytest
import strawberry

@strawberry.type
class Subscription:
@strawberry.subscription
async def count(self, target: int = 100) -> int:
for i in range(target):
yield i
await asyncio.sleep(0.5)

@strawberry.type
class Query:
@strawberry.field
def hello() -> str:
return "world"

schema = strawberry.Schema(query=Query, subscription=Subscription)
sighclone marked this conversation as resolved.
Show resolved Hide resolved

@pytest.mark.asyncio
async def test_subscription():
query = """
Expand Down