mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-20 21:40:36 +03:00
Add logging of errors in execution
This commit is contained in:
parent
4d5132d925
commit
4e5862f8fb
|
@ -1,6 +1,7 @@
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import traceback
|
||||||
|
|
||||||
from asyncio import gather, coroutines
|
from asyncio import gather, coroutines
|
||||||
|
|
||||||
|
@ -519,7 +520,9 @@ class AsyncGraphQLView(GraphQLView):
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.batch:
|
if self.batch:
|
||||||
responses = await gather(*[self.get_response(request, entry) for entry in data])
|
responses = await gather(
|
||||||
|
*[self.get_response(request, entry) for entry in data]
|
||||||
|
)
|
||||||
result = "[{}]".format(
|
result = "[{}]".format(
|
||||||
",".join([response[0] for response in responses])
|
",".join([response[0] for response in responses])
|
||||||
)
|
)
|
||||||
|
@ -529,7 +532,9 @@ class AsyncGraphQLView(GraphQLView):
|
||||||
or 200
|
or 200
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
result, status_code = await self.get_response(request, data, show_graphiql)
|
result, status_code = await self.get_response(
|
||||||
|
request, data, show_graphiql
|
||||||
|
)
|
||||||
|
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
status=status_code, content=result, content_type="application/json"
|
status=status_code, content=result, content_type="application/json"
|
||||||
|
@ -558,6 +563,9 @@ class AsyncGraphQLView(GraphQLView):
|
||||||
response = {}
|
response = {}
|
||||||
|
|
||||||
if execution_result.errors:
|
if execution_result.errors:
|
||||||
|
for e in execution_result.errors:
|
||||||
|
print(e)
|
||||||
|
traceback.print_tb(e.__traceback__)
|
||||||
set_rollback()
|
set_rollback()
|
||||||
response["errors"] = [
|
response["errors"] = [
|
||||||
self.format_error(e) for e in execution_result.errors
|
self.format_error(e) for e in execution_result.errors
|
||||||
|
|
Loading…
Reference in New Issue
Block a user