Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
GraphQL now prints exceptions to stderr as well as returning them or not
NyanKiyoshifc18db2b20bb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 290683e0c7..d9bb82c923 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,7 @@ All notable, unreleased changes to this project will be documented in this file.- Add support for Google Cloud Storage - #4127 by @chetabahana- Fix wrong calculation of subtotal in cart page - #4145 by @korycins- Fix multiple checkbox selected behavior - #4146 by @benekex2+- GraphQL now prints exceptions to stderr as well as returning them or not - #4148 by @NyanKiyoshi## 2.6.0diff --git a/saleor/graphql/views.py b/saleor/graphql/views.pyindex 2de768e297..564fa33c0b 100644--- a/saleor/graphql/views.py+++ b/saleor/graphql/views.py@@ -1,4 +1,5 @@import json+import loggingimport tracebackfrom django.conf import settings@@ -15,6 +16,8 @@ from graphql.error import ()from graphql.execution import ExecutionResult+logger = logging.getLogger(__name__)+class GraphQLView(View):# This class is our implementation of `graphene_django.views.GraphQLView`,@@ -190,10 +193,14 @@ class GraphQLView(View):result = format_graphql_error(error)else:result = {"message": str(error)}++ exc = error+ while isinstance(exc, GraphQLError) and hasattr(exc, "original_error"):+ exc = exc.original_error++ logger.error("Exception information:", exc_info=exc)+if settings.DEBUG:- exc = error- while isinstance(exc, GraphQLError) and hasattr(exc, "original_error"):- exc = exc.original_errorlines = []for line in traceback.format_exception(type(exc), exc, exc.__traceback__):lines.extend(line.rstrip().splitlines())