diff --git a/graphene_django/tests/test_views.py b/graphene_django/tests/test_views.py index 7293423..80649d0 100644 --- a/graphene_django/tests/test_views.py +++ b/graphene_django/tests/test_views.py @@ -413,9 +413,8 @@ def test_supports_pretty_printing_by_request(client): def test_handles_field_errors_caught_by_graphql(client): response = client.get(url_string(query='{thrower}')) - assert response.status_code == 200 + assert response.status_code == 400 assert response_json(response) == { - 'data': None, 'errors': [{'locations': [{'column': 2, 'line': 1}], 'message': 'Throws!'}] } diff --git a/graphene_django/views.py b/graphene_django/views.py index 4129668..5916aaf 100644 --- a/graphene_django/views.py +++ b/graphene_django/views.py @@ -154,7 +154,7 @@ class GraphQLView(View): if execution_result.errors: response['errors'] = [self.format_error(e) for e in execution_result.errors] - if execution_result.invalid: + if execution_result.invalid or execution_result.errors: status_code = 400 else: response['data'] = execution_result.data