Skip to content

Commit 13d4edb

Browse files
committed
chore: Use standard HTTP status code
1 parent c52cf2b commit 13d4edb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

graphene_django/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
import json
33
import re
4+
from http import HTTPStatus
45

56
from django.db import connection, transaction
67
from django.http import HttpResponse, HttpResponseNotAllowed
@@ -195,7 +196,7 @@ def dispatch(self, request, *args, **kwargs):
195196
status_code = (
196197
responses
197198
and max(responses, key=lambda response: response[1])[1]
198-
or 200
199+
or HTTPStatus.OK
199200
)
200201
else:
201202
result, status_code = self.get_response(request, data, show_graphiql)
@@ -222,7 +223,7 @@ def get_response(self, request, data, show_graphiql=False):
222223
if getattr(request, MUTATION_ERRORS_FLAG, False) is True:
223224
set_rollback()
224225

225-
status_code = 200
226+
status_code = HTTPStatus.OK
226227
if execution_result:
227228
response = {}
228229

@@ -235,7 +236,7 @@ def get_response(self, request, data, show_graphiql=False):
235236
if execution_result.errors and any(
236237
not getattr(e, "path", None) for e in execution_result.errors
237238
):
238-
status_code = 400
239+
status_code = HTTPStatus.BAD_REQUEST
239240
else:
240241
response["data"] = execution_result.data
241242

0 commit comments

Comments
 (0)