mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Update middleware example to support introspection
In the `timing_middleware` example, introspection queries will fail due to `Schema` and others not having `_meta` attributes. API will work and tests pass but introspection will fail, which can be quite confusing to the developer. Simple update makes sure the `root` variable has a `_meta` attribute before accessing it.
This commit is contained in:
parent
a0fc843513
commit
035ff7ef88
|
@ -57,7 +57,7 @@ logs the time it takes to resolve each field
|
|||
return_value = next(root, info, **args)
|
||||
duration = timer() - start
|
||||
logger.debug("{parent_type}.{field_name}: {duration} ms".format(
|
||||
parent_type=root._meta.name if root else '',
|
||||
parent_type=root._meta.name if root and hasattr(root, '_meta') else '',
|
||||
field_name=info.field_name,
|
||||
duration=round(duration * 1000, 2)
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue
Block a user