Back to Strawberry

0.320.0 Breaking Changes

docs/breaking-changes/0.320.0.md

0.320.11.5 KB
Original Source

v0.320.0 makes multipart subscriptions opt-in

This release adds support for GraphQL subscriptions over Server-Sent Events (SSE). As part of that work, streaming transports are now selected from your integration's subscription_protocols, which changes how multipart subscriptions are enabled.

Multipart subscriptions are now opt-in

Previously, multipart subscriptions were enabled unconditionally: any request sent with an Accept: multipart/mixed header was served as a multipart subscription stream, regardless of the subscription_protocols you configured.

Now a streaming transport (multipart subscriptions or SSE) is only active when its protocol is listed in subscription_protocols. The default (graphql-transport-ws and graphql-ws) does not include the multipart protocol, so if you relied on multipart subscriptions you need to enable them explicitly by adding MULTIPART_SUBSCRIPTION_PROTOCOL:

python
from strawberry.asgi import GraphQL
from strawberry.subscriptions import (
    GRAPHQL_TRANSPORT_WS_PROTOCOL,
    GRAPHQL_WS_PROTOCOL,
    MULTIPART_SUBSCRIPTION_PROTOCOL,
)

app = GraphQL(
    schema,
    subscription_protocols=[
        GRAPHQL_TRANSPORT_WS_PROTOCOL,
        GRAPHQL_WS_PROTOCOL,
        MULTIPART_SUBSCRIPTION_PROTOCOL,
    ],
)

The same applies to SSE, which is enabled with GRAPHQL_SSE_PROTOCOL. Both constants are importable from strawberry.subscriptions.

If you do not use multipart subscriptions, no changes are required.