strawberry.channels.GraphQLProtocolTypeRouter

HTTP and Websocket GraphQL type router.

Convenience class to set up GraphQL on both HTTP and Websocket, optionally with a Django application for all other HTTP routes.

from strawberry.channels import GraphQLProtocolTypeRouter
from django.core.asgi import get_asgi_application
django_asgi = get_asgi_application()
from myapi import schema
application = GraphQLProtocolTypeRouter(
schema,
django_application=django_asgi,
)

This will route all requests to /graphql on either HTTP or websockets to us, and everything else to the Django application.

Constructor:

Signature:

def __init__(
self,
schema: BaseSchema,
django_application: str | None = None,
url_pattern: str = '^graphql',
) -> None:
...

Parameters:

  1. schema:

    Type
    BaseSchema
  2. django_application:

    Type
    str | None
    Default
    None
  3. url_pattern:

    Type
    str
    Default
    '^graphql'