Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Catch graphql syntax errors

Unknowna72973e58416
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
index 94eac6823d..6dc710d0f3 100644
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -7,7 +7,8 @@ from django.views.generic import View
from graphene_django.settings import graphene_settings
from graphene_django.views import instantiate_middleware
from graphql import get_default_backend
-from graphql.error import GraphQLError, format_error as format_graphql_error
+from graphql.error import (
+ GraphQLError, GraphQLSyntaxError, format_error as format_graphql_error)
from graphql.execution import ExecutionResult
@@ -116,7 +117,7 @@ class GraphQLView(View):
invalid=True)
try:
document = self.backend.document_from_string(self.schema, query)
- except ValueError as e:
+ except (ValueError, GraphQLSyntaxError) as e:
return ExecutionResult(errors=[e], invalid=True)
extra_options = {}
if self.executor: