From b4b9677c1d245e049dec118e8bec8aef55fe3098 Mon Sep 17 00:00:00 2001 From: Jaime Herencia Enjuto Date: Wed, 11 Aug 2021 19:53:27 +0200 Subject: [PATCH] making wss path configurable --- graphql_ws/django/routing.py | 3 ++- graphql_ws/django/settings.py | 3 +++ graphql_ws/django/templates/graphene/graphiql.html | 3 ++- graphql_ws/django/templatetags/__init__.py | 0 graphql_ws/django/templatetags/graphql_ws.py | 9 +++++++++ 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 graphql_ws/django/settings.py create mode 100644 graphql_ws/django/templatetags/__init__.py create mode 100644 graphql_ws/django/templatetags/graphql_ws.py diff --git a/graphql_ws/django/routing.py b/graphql_ws/django/routing.py index 15a1356..d5a0c1a 100644 --- a/graphql_ws/django/routing.py +++ b/graphql_ws/django/routing.py @@ -3,6 +3,7 @@ from django.apps import apps from django.urls import path from .consumers import GraphQLSubscriptionConsumer +from .settings import graphql_ws_path if apps.is_installed("django.contrib.auth"): from channels.auth import AuthMiddlewareStack @@ -10,7 +11,7 @@ AuthMiddlewareStack = None -websocket_urlpatterns = [path("subscriptions", GraphQLSubscriptionConsumer)] +websocket_urlpatterns = [path(graphql_ws_path, GraphQLSubscriptionConsumer)] application = ProtocolTypeRouter({"websocket": URLRouter(websocket_urlpatterns)}) diff --git a/graphql_ws/django/settings.py b/graphql_ws/django/settings.py new file mode 100644 index 0000000..766f272 --- /dev/null +++ b/graphql_ws/django/settings.py @@ -0,0 +1,3 @@ +from django.conf import settings + +graphql_ws_path = getattr(settings, "GRAPHQL_WS_PATH", "subscriptions") diff --git a/graphql_ws/django/templates/graphene/graphiql.html b/graphql_ws/django/templates/graphene/graphiql.html index dce2683..526dc33 100644 --- a/graphql_ws/django/templates/graphene/graphiql.html +++ b/graphql_ws/django/templates/graphene/graphiql.html @@ -1,3 +1,4 @@ +{% load graphql_ws %}