Skip to content

Commit 035ff7e

Browse files
committed
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.
1 parent a0fc843 commit 035ff7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/execution/middleware.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ logs the time it takes to resolve each field
5757
return_value = next(root, info, **args)
5858
duration = timer() - start
5959
logger.debug("{parent_type}.{field_name}: {duration} ms".format(
60-
parent_type=root._meta.name if root else '',
60+
parent_type=root._meta.name if root and hasattr(root, '_meta') else '',
6161
field_name=info.field_name,
6262
duration=round(duration * 1000, 2)
6363
))

0 commit comments

Comments
 (0)