mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Improved django debug
This commit is contained in:
parent
14439155ee
commit
bee0af1125
|
@ -42,13 +42,11 @@ class DebugSchema(Schema):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def query(self):
|
def query(self):
|
||||||
if not self._query:
|
return self._query
|
||||||
return
|
|
||||||
return debug_objecttype(self._query)
|
|
||||||
|
|
||||||
@query.setter
|
@query.setter
|
||||||
def query(self, value):
|
def query(self, value):
|
||||||
self._query = value
|
self._query = value and debug_objecttype(value)
|
||||||
|
|
||||||
def enable_instrumentation(self, wrapped_root):
|
def enable_instrumentation(self, wrapped_root):
|
||||||
# This is thread-safe because database connections are thread-local.
|
# This is thread-safe because database connections are thread-local.
|
||||||
|
@ -59,10 +57,9 @@ class DebugSchema(Schema):
|
||||||
for connection in connections.all():
|
for connection in connections.all():
|
||||||
unwrap_cursor(connection)
|
unwrap_cursor(connection)
|
||||||
|
|
||||||
def execute(self, *args, **kwargs):
|
def execute(self, query, root=None, *args, **kwargs):
|
||||||
root = kwargs.pop('root', object())
|
|
||||||
wrapped_root = WrappedRoot(root=root)
|
wrapped_root = WrappedRoot(root=root)
|
||||||
self.enable_instrumentation(wrapped_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()
|
self.disable_instrumentation()
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -100,7 +100,7 @@ class NormalCursorWrapper(object):
|
||||||
return method(sql, params)
|
return method(sql, params)
|
||||||
finally:
|
finally:
|
||||||
stop_time = time()
|
stop_time = time()
|
||||||
duration = (stop_time - start_time) * 1000
|
duration = (stop_time - start_time)
|
||||||
_params = ''
|
_params = ''
|
||||||
try:
|
try:
|
||||||
_params = json.dumps(list(map(self._decode, params)))
|
_params = json.dumps(list(map(self._decode, params)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user