File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Websocket server for GraphQL subscriptions.
55Currently supports:
66* [ aiohttp] ( https://github.com/graphql-python/graphql-ws#aiohttp )
77* [ Gevent] ( https://github.com/graphql-python/graphql-ws#gevent )
8+ * Sanic (uses [ websockets] ( https://github.com/aaugustin/websockets/ ) library)
89
910# Installation instructions
1011
@@ -40,6 +41,27 @@ app.router.add_get('/subscriptions', subscriptions)
4041web.run_app(app, port = 8000 )
4142```
4243
44+ ### Sanic
45+
46+ Works with any framework that uses the websockets library for
47+ it's websocket implementation. For this example, plug in
48+ your Sanic server.
49+
50+ ``` python
51+ from graphql_ws.websockets_lib import WsLibSubscriptionServer
52+
53+
54+ subscription_server = WsLibSubscriptionServer(schema)
55+
56+ @app.websocket (' /subscriptions' , subprotocols = [' graphql-ws' ])
57+ async def subscriptions (request , ws ):
58+ await subscription_server.handle(ws)
59+ return ws
60+
61+
62+ app.run(host = " 0.0.0.0" , port = 8000 )
63+ ```
64+
4365And then, plug into a subscribable schema:
4466
4567``` python
You can’t perform that action at this time.
0 commit comments