Strawberry GraphQL @ 0.240.0

Released

This release adds support for schema-extensions in subscriptions.

Here’s a small example of how to use them (they work the same way as query and mutation extensions):

import asyncio
from typing import AsyncIterator
import strawberry
from strawberry.extensions.base_extension import SchemaExtension
@strawberry.type
class Subscription:
@strawberry.subscription
async def notifications(self, info: strawberry.Info) -> AsyncIterator[str]:
for _ in range(3):
yield "Hello"
class MyExtension(SchemaExtension):
async def on_operation(self):
# This would run when the subscription starts
print("Subscription started")
yield
# The subscription has ended
print("Subscription ended")
schema = strawberry.Schema(
query=Query, subscription=Subscription, extensions=[MyExtension]
)

Releases contributed by @nrbnlulu via #3554