Skip to content

Commit

Permalink
fix: query suggestions are enabled when debugging
Browse files Browse the repository at this point in the history
Also move DEBUG logic part of ENABLE_GRAPHIQL and
ENABLE_GRAPHQL_INTROSPECTION into settings.py

Refs: HP-2351
  • Loading branch information
charn committed May 2, 2024
1 parent 8556826 commit 0e2ad73
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions open_city_profile/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion open_city_profile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down
2 changes: 1 addition & 1 deletion open_city_profile/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0e2ad73

Please sign in to comment.