From 13d4edbd228e2740ad0c04aaa79de978417fd309 Mon Sep 17 00:00:00 2001 From: rapsealk Date: Mon, 14 Apr 2025 11:04:33 +0900 Subject: [PATCH] chore: Use standard HTTP status code --- graphene_django/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/graphene_django/views.py b/graphene_django/views.py index 1ec6598..4422f75 100644 --- a/graphene_django/views.py +++ b/graphene_django/views.py @@ -1,6 +1,7 @@ import inspect import json import re +from http import HTTPStatus from django.db import connection, transaction from django.http import HttpResponse, HttpResponseNotAllowed @@ -195,7 +196,7 @@ class GraphQLView(View): status_code = ( responses and max(responses, key=lambda response: response[1])[1] - or 200 + or HTTPStatus.OK ) else: result, status_code = self.get_response(request, data, show_graphiql) @@ -222,7 +223,7 @@ class GraphQLView(View): if getattr(request, MUTATION_ERRORS_FLAG, False) is True: set_rollback() - status_code = 200 + status_code = HTTPStatus.OK if execution_result: response = {} @@ -235,7 +236,7 @@ class GraphQLView(View): if execution_result.errors and any( not getattr(e, "path", None) for e in execution_result.errors ): - status_code = 400 + status_code = HTTPStatus.BAD_REQUEST else: response["data"] = execution_result.data