From b6fea3a4540f7613643315fa9e225a3eeaeb15d9 Mon Sep 17 00:00:00 2001 From: Adam Charnock Date: Mon, 16 Nov 2015 12:03:55 +0000 Subject: [PATCH] Adding exception loggging The error reporting code swallows exceptions in order to report them to the client. When debugging (and when getting started with graphql as I am) it is very useful to be able to see the exception stack traces. I have therefore added a single logging statement to `Executor.run_resolve_fn()`. Is it possible that logging is also required elsewhere, I'm happy to take any advice this. --- graphql/core/execution/executor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/graphql/core/execution/executor.py b/graphql/core/execution/executor.py index 6b762370..07cb0c02 100644 --- a/graphql/core/execution/executor.py +++ b/graphql/core/execution/executor.py @@ -1,5 +1,6 @@ import collections import functools +import logging from ..error import GraphQLError from ..language import ast @@ -14,6 +15,9 @@ get_field_def, get_operation_root_type +logger = logging.getLogger(__name__) + + class Executor(object): def __init__(self, execution_middlewares=None, default_resolver=default_resolve_fn, map_type=dict): assert issubclass(map_type, collections.MutableMapping) @@ -316,4 +320,5 @@ def run_resolve_fn(self, resolve_fn, source, args, info): return curried_resolve_fn() except Exception as e: + logger.info(e, exc_info=True) return e