From bee0af11251e93fd45c2c83176e63b3506623c61 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 4 Dec 2015 02:34:12 -0800 Subject: [PATCH] Improved django debug --- graphene/contrib/django/debug/schema.py | 11 ++++------- graphene/contrib/django/debug/sql/tracking.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/graphene/contrib/django/debug/schema.py b/graphene/contrib/django/debug/schema.py index 443f2545..2726f3fb 100644 --- a/graphene/contrib/django/debug/schema.py +++ b/graphene/contrib/django/debug/schema.py @@ -42,13 +42,11 @@ class DebugSchema(Schema): @property def query(self): - if not self._query: - return - return debug_objecttype(self._query) + return self._query @query.setter def query(self, value): - self._query = value + self._query = value and debug_objecttype(value) def enable_instrumentation(self, wrapped_root): # This is thread-safe because database connections are thread-local. @@ -59,10 +57,9 @@ class DebugSchema(Schema): for connection in connections.all(): unwrap_cursor(connection) - def execute(self, *args, **kwargs): - root = kwargs.pop('root', object()) + def execute(self, query, root=None, *args, **kwargs): wrapped_root = WrappedRoot(root=root) self.enable_instrumentation(wrapped_root) - result = super(DebugSchema, self).execute(root=wrapped_root, *args, **kwargs) + result = super(DebugSchema, self).execute(query, wrapped_root, *args, **kwargs) self.disable_instrumentation() return result diff --git a/graphene/contrib/django/debug/sql/tracking.py b/graphene/contrib/django/debug/sql/tracking.py index 487b092c..8ed40492 100644 --- a/graphene/contrib/django/debug/sql/tracking.py +++ b/graphene/contrib/django/debug/sql/tracking.py @@ -100,7 +100,7 @@ class NormalCursorWrapper(object): return method(sql, params) finally: stop_time = time() - duration = (stop_time - start_time) * 1000 + duration = (stop_time - start_time) _params = '' try: _params = json.dumps(list(map(self._decode, params)))