From 035ff7ef885e9e158093359e93e5723298ab177e Mon Sep 17 00:00:00 2001 From: Dean Kleissas Date: Wed, 24 Jan 2018 16:48:14 -0500 Subject: [PATCH] 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. --- docs/execution/middleware.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/execution/middleware.rst b/docs/execution/middleware.rst index 203cd881..55efe730 100644 --- a/docs/execution/middleware.rst +++ b/docs/execution/middleware.rst @@ -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) ))