From e2fb9e1f2b9969dce0522b09032005ba0b4e78ab Mon Sep 17 00:00:00 2001 From: Juha Louhiranta Date: Thu, 2 May 2024 12:50:48 +0300 Subject: [PATCH] fix: query suggestions are enabled when debugging Also move DEBUG logic part of ENABLE_GRAPHIQL and ENABLE_GRAPHQL_INTROSPECTION into settings.py Refs: HP-2351 --- open_city_profile/settings.py | 4 ++-- open_city_profile/urls.py | 2 +- open_city_profile/views.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/open_city_profile/settings.py b/open_city_profile/settings.py index b7fc1e9b..b71615e2 100644 --- a/open_city_profile/settings.py +++ b/open_city_profile/settings.py @@ -165,9 +165,9 @@ DEFAULT_FROM_EMAIL = env.str("DEFAULT_FROM_EMAIL") # Set to True to enable GraphiQL interface, enabled automatically if DEBUG=True -ENABLE_GRAPHIQL = env("ENABLE_GRAPHIQL") +ENABLE_GRAPHIQL = env("ENABLE_GRAPHIQL") or env("DEBUG") # Enable GraphQL introspection queries, enabled automatically if DEBUG=True -ENABLE_GRAPHQL_INTROSPECTION = env("ENABLE_GRAPHQL_INTROSPECTION") +ENABLE_GRAPHQL_INTROSPECTION = env("ENABLE_GRAPHQL_INTROSPECTION") or env("DEBUG") if not ENABLE_GRAPHQL_INTROSPECTION: enable_graphql_query_suggestion(False) diff --git a/open_city_profile/urls.py b/open_city_profile/urls.py index 7b829fd1..cf2a6ddc 100644 --- a/open_city_profile/urls.py +++ b/open_city_profile/urls.py @@ -19,7 +19,7 @@ csp_exempt( csrf_exempt( GraphQLView.as_view( - graphiql=settings.ENABLE_GRAPHIQL or settings.DEBUG, + graphiql=settings.ENABLE_GRAPHIQL, execution_context_class=DeferredExecutionContext, ) ) diff --git a/open_city_profile/views.py b/open_city_profile/views.py index d373637e..58d9ca74 100644 --- a/open_city_profile/views.py +++ b/open_city_profile/views.py @@ -104,7 +104,7 @@ def _run_custom_validators(self, query): depth_limit_validator(max_depth=settings.GRAPHQL_QUERY_DEPTH_LIMIT) ] - if not settings.ENABLE_GRAPHQL_INTROSPECTION and not settings.DEBUG: + if not settings.ENABLE_GRAPHQL_INTROSPECTION: validation_rules.append(DisableIntrospection) try: