Skip to content

Commit

Permalink
Fixes #1163
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Dec 7, 2022
1 parent c351b62 commit 36589a0
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/resolver_utils/container.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 36589a0

Please sign in to comment.