Skip to content

Commit c471860

Browse files
committed
Simplified logic a bit more
1 parent b93c73a commit c471860

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/graphql_server/http/async_base_view.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,20 +341,19 @@ async def run(
341341

342342
allowed_operation_types = operation_type_from_http(request_adapter.method)
343343

344-
if not self.allow_queries_via_get and request_adapter.method == "GET":
345-
allowed_operation_types = allowed_operation_types - {OperationType.QUERY}
346-
347344
if request_adapter.method == "GET":
348345
if not self.allow_queries_via_get:
349346
allowed_operation_types = allowed_operation_types - {
350347
OperationType.QUERY
351348
}
352349

353-
should_render_graphql_ide = self.should_render_graphql_ide(request_adapter)
354350
if self.graphql_ide:
355-
if should_render_graphql_ide:
351+
if self.should_render_graphql_ide(request_adapter):
356352
return await self.render_graphql_ide(request, request_data)
357-
elif should_render_graphql_ide:
353+
elif (
354+
not request_adapter.content_type
355+
or "application/json" not in request_adapter.content_type
356+
):
358357
raise HTTPException(404, "Not Found") # pragma: no cover
359358

360359
sub_response = await self.get_sub_response(request)

src/graphql_server/http/sync_base_view.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,13 @@ def run(
193193
OperationType.QUERY
194194
}
195195

196-
should_render_graphql_ide = self.should_render_graphql_ide(request_adapter)
197196
if self.graphql_ide:
198-
if should_render_graphql_ide:
197+
if self.should_render_graphql_ide(request_adapter):
199198
return self.render_graphql_ide(request, request_data)
200-
elif should_render_graphql_ide:
199+
elif (
200+
not request_adapter.content_type
201+
or "application/json" not in request_adapter.content_type
202+
):
201203
raise HTTPException(404, "Not Found") # pragma: no cover
202204

203205
sub_response = self.get_sub_response(request)

0 commit comments

Comments
 (0)