Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GET requests with content_type headers #3452

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: patch

This change fixes GET request queries returning a 400 if a content_type header is supplied
6 changes: 3 additions & 3 deletions strawberry/http/async_base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ async def parse_http_body(
) -> GraphQLRequestData:
content_type = request.content_type or ""

if "application/json" in content_type:
if request.method == "GET":
data = self.parse_query_params(request.query_params)
elif "application/json" in content_type:
data = self.parse_json(await request.get_body())
elif content_type.startswith("multipart/form-data"):
data = await self.parse_multipart(request)
elif request.method == "GET":
data = self.parse_query_params(request.query_params)
else:
raise HTTPException(400, "Unsupported content type")

Expand Down
6 changes: 3 additions & 3 deletions strawberry/http/sync_base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ def parse_multipart(self, request: SyncHTTPRequestAdapter) -> Dict[str, str]:
def parse_http_body(self, request: SyncHTTPRequestAdapter) -> GraphQLRequestData:
content_type = request.content_type or ""

if "application/json" in content_type:
if request.method == "GET":
data = self.parse_query_params(request.query_params)
elif "application/json" in content_type:
data = self.parse_json(request.body)
elif content_type.startswith("multipart/form-data"):
data = self.parse_multipart(request)
elif request.method == "GET":
data = self.parse_query_params(request.query_params)
else:
raise HTTPException(400, "Unsupported content type")

Expand Down