From 36589a0f03c3e6c07c5fe5377dab9b0ecfcedf7f Mon Sep 17 00:00:00 2001 From: Sunli Date: Wed, 7 Dec 2022 15:48:48 +0800 Subject: [PATCH] Fixes #1163 --- src/resolver_utils/container.rs | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/resolver_utils/container.rs b/src/resolver_utils/container.rs index 236983401..fd4b5dbe4 100644 --- a/src/resolver_utils/container.rs +++ b/src/resolver_utils/container.rs @@ -5,7 +5,7 @@ use indexmap::IndexMap; use crate::{ extensions::ResolveInfo, parser::types::Selection, Context, ContextBase, ContextSelectionSet, - Error, IntrospectionMode, Name, OutputType, ServerError, ServerResult, Value, + Error, Name, OutputType, ServerError, ServerResult, Value, }; /// Represents a GraphQL container object. @@ -188,27 +188,14 @@ impl<'a> Fields<'a> { match &selection.node { Selection::Field(field) => { if field.node.name.node == "__typename" { - if matches!( - ctx.schema_env.registry.introspection_mode, - IntrospectionMode::Enabled | IntrospectionMode::IntrospectionOnly - ) && matches!( - ctx.query_env.introspection_mode, - IntrospectionMode::Enabled | IntrospectionMode::IntrospectionOnly, - ) { - // Get the typename - let ctx_field = ctx.with_field(field); - let field_name = ctx_field.item.node.response_key().node.clone(); - let typename = root.introspection_type_name().into_owned(); - - self.0.push(Box::pin(async move { - Ok((field_name, Value::String(typename))) - })); - } else { - self.0.push(Box::pin(async move { - Ok((field.node.response_key().node.clone(), Value::Null)) - })); - } - + // Get the typename + let ctx_field = ctx.with_field(field); + let field_name = ctx_field.item.node.response_key().node.clone(); + let typename = root.introspection_type_name().into_owned(); + + self.0.push(Box::pin(async move { + Ok((field_name, Value::String(typename))) + })); continue; }