Releases: strawberry-graphql/strawberry
🍓 0.242.0
Starting with this release, clients using the legacy graphql-ws subprotocol will receive an error when they try to send binary data frames.
Before, binary data frames were silently ignored.
While vaguely defined in the protocol, the legacy graphql-ws subprotocol is generally understood to only support text data frames.
Releases contributed by @DoctorJohn via #3633
🍓 0.241.0
You can now configure your schemas to provide a custom subclass of
strawberry.types.Info
to your types and queries.
import strawberry
from strawberry.schema.config import StrawberryConfig
from .models import ProductModel
class CustomInfo(strawberry.Info):
@property
def selected_group_id(self) -> int | None:
"""Get the ID of the group you're logged in as."""
return self.context["request"].headers.get("Group-ID")
@strawberry.type
class Group:
id: strawberry.ID
name: str
@strawberry.type
class User:
id: strawberry.ID
name: str
group: Group
@strawberry.type
class Query:
@strawberry.field
def user(self, id: strawberry.ID, info: CustomInfo) -> Product:
kwargs = {"id": id, "name": ...}
if info.selected_group_id is not None:
# Get information about the group you're a part of, if
# available.
kwargs["group"] = ...
return User(**kwargs)
schema = strawberry.Schema(
Query,
config=StrawberryConfig(info_class=CustomInfo),
)
Releases contributed by @parafoxia via #3592
🍓 0.240.4
🍓 0.240.3
🍓 0.240.2
🍓 0.240.1
🍓 0.240.0
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]
)
🍓 0.239.2
🍓 0.239.1
This release fixes an issue with the http multipart subscription where the
status code would be returned as None
, instead of 200.
We also took the opportunity to update the internals to better support
additional protocols in future.
Releases contributed by @patrick91 via #3610
🍓 0.239.0
This release adds support for multipart subscriptions in almost all1 of our
http integrations!
Multipart subcriptions
are a new protocol from Apollo GraphQL, built on the
Incremental Delivery over HTTP spec,
which is also used for @defer
and @stream
.
The main advantage of this protocol is that when using the Apollo Client
libraries you don't need to install any additional dependency, but in future
this feature should make it easier for us to implement @defer
and @stream
Also, this means that you don't need to use Django Channels for subscription,
since this protocol is based on HTTP we don't need to use websockets.
Releases contributed by @patrick91 via #3076
-
Flask, Chalice and the sync Django integration don't support this. ↩