|
@@ -1,6 +1,6 @@
|
|
|
from django.conf import settings
|
|
from django.conf import settings
|
|
|
from django.contrib.auth.views import redirect_to_login
|
|
from django.contrib.auth.views import redirect_to_login
|
|
|
-from django.http import HttpResponseForbidden
|
|
|
|
|
|
|
+from django.http import HttpResponseNotFound, HttpResponseForbidden
|
|
|
from django.urls import reverse
|
|
from django.urls import reverse
|
|
|
from graphene_django.views import GraphQLView as GraphQLView_
|
|
from graphene_django.views import GraphQLView as GraphQLView_
|
|
|
from rest_framework.exceptions import AuthenticationFailed
|
|
from rest_framework.exceptions import AuthenticationFailed
|
|
@@ -14,6 +14,10 @@ class GraphQLView(GraphQLView_):
|
|
|
"""
|
|
"""
|
|
|
def dispatch(self, request, *args, **kwargs):
|
|
def dispatch(self, request, *args, **kwargs):
|
|
|
|
|
|
|
|
|
|
+ # Enforce GRAPHQL_ENABLED
|
|
|
|
|
+ if not settings.GRAPHQL_ENABLED:
|
|
|
|
|
+ return HttpResponseNotFound("The GraphQL API is not enabled.")
|
|
|
|
|
+
|
|
|
# Attempt to authenticate the user using a DRF token, if provided
|
|
# Attempt to authenticate the user using a DRF token, if provided
|
|
|
if not request.user.is_authenticated:
|
|
if not request.user.is_authenticated:
|
|
|
authenticator = TokenAuthentication()
|
|
authenticator = TokenAuthentication()
|