Sanic + GraphQL

I’m trying to leverage Ariadne ( graphql project within Sanic to give myself some graphql endpoints. I’m able to get this to work just fine for a standard get/post endpoint within sanic; however, I’m having trouble with the websocket / subscription endpoint. Supposedly all you need an asgi server and websockets (both of which Sanic has), but I can’t figure out how to hook it up.

My normal process for websockets is:

    ["auth:user", "auth:apitoken_user"], False
)  # user or user-level api token are ok
async def ws_tasks(request, ws, user):
    # open connection to db
    # listen for updates from db and send them through ws 

In other asgi applications, they’re able to do the following (from

from ariadne.asgi import GraphQL
from starlette.routing import Route, WebSocketRoute
routers = [
    Route("/graphql", GraphQL(schema=schema, debug=True)),
    WebSocketRoute("/graphql", GraphQL(schema=schema, debug=True)),

app = Starlette(debug=True, routes=routers)

and essentially just plug it in. When I try to do something similar with Sanic (app.add_websocket_route(GraphQL(schema=schema, debug=True), "/graphql") I get AttributeError: 'GraphQL' object has no attribute '__name__'

Sorry I did not get back sooner. I will dig something out and share. I was playing around with ariadne a few months back.