10000 Bring changes from #74 · graphql-python/graphql-ws@a360cf6 · GitHub
[go: up one dir, main page]

Skip to content

Commit a360cf6

Browse files
committed
Bring changes from #74
1 parent 6c26537 commit a360cf6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

graphql_ws/django/routing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from channels import __version__ as channels_version
12
from channels.routing import ProtocolTypeRouter, URLRouter
23
from channels.sessions import SessionMiddlewareStack
4+
from django.utils.version import get_version_tuple
35
from django.apps import apps
46
from django.urls import path
57
from .consumers import GraphQLSubscriptionConsumer
@@ -10,7 +12,13 @@
1012
AuthMiddlewareStack = None
1113

1214

13-
websocket_urlpatterns = [path("subscriptions", GraphQLSubscriptionConsumer)]
15+
channels_version_tuple = get_version_tuple(channels_version)
16+
17+
18+
if channels_version_tuple > (3, 0 , 0):
19+
websocket_urlpatterns = [path("subscriptions", GraphQLSubscriptionConsumer.as_asgi())]
20+
else:
21+
websocket_urlpatterns = [path("subscriptions", GraphQLSubscriptionConsumer)]
1422

1523
application = ProtocolTypeRouter({"websocket": URLRouter(websocket_urlpatterns)})
1624

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ test =
5757
channels==1.*; python_version<"3"
5858
django==2.*; python_version>="3"
5959
channels==2.*; python_version>="3"
60+
django==3.*; python_version>="3"
61+
channels==3.*; python_version>="3"
6062
aiohttp; python_version>="3.5"
6163

6264
[bdist_wheel]

0 commit comments

Comments
 (0)
0