How can I disable the GraphiQL IDE on production?
Hi @amiyatulu - this is how I do it:
In urls.py I import the settings.DEBUG value and then add graphiql ONLY if debug is true:
from django.conf import settings
url_patterns = [...normal_patterns]
if settings.DEBUG:
url_patterns.extend([...graphiql_url])
Thanks,
This is my code in urls.py:
if settings.DEBUG:
urlpatterns += path('graphql', csrf_exempt(jwt_cookie(GraphQLView.as_view(graphiql=True)))),
else:
urlpatterns += path('graphql', csrf_exempt(jwt_cookie(GraphQLView.as_view()))),
Might as well use
path('graphql/', GraphQLView.as_view(graphiql=settings.DEBUG), name='graphql')
Most helpful comment
Might as well use