Multipart subscriptions
Strawberry supports subscription over multipart responses. This is an alternative protocol created by Apollo to support subscriptions over HTTP, and it is supported by default by Apollo Client.
Support
We support multipart subscriptions in the following HTTP libraries:
- Django (only in the Async view)
- ASGI
- Litestar
- FastAPI
- AioHTTP
- Quart
Usage
Multipart subscriptions are opt-in. Enable them by including
MULTIPART_SUBSCRIPTION_PROTOCOL in your integrationβs
subscription_protocols :
from strawberry.fastapi import GraphQLRouterfrom strawberry.subscriptions import ( GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL, MULTIPART_SUBSCRIPTION_PROTOCOL,)
from api.schema import schema
graphql_router = GraphQLRouter( schema, subscription_protocols=[ GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL, MULTIPART_SUBSCRIPTION_PROTOCOL, ],)