Skip to content

Commit 06c85f3

Browse files
committed
dynamic: fixed __typename always returned null when introspection was disabled.
1 parent 60e353e commit 06c85f3

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [7.0.16] 2025-03-20
8+
9+
- dynamic: fixed `__typename` always returned `null` when introspection was disabled.
10+
711
# [7.0.15] 2025-02-03
812

913
- feat: Add `custom-error-conversion` feature [#1631](https://github.com/async-graphql/async-graphql/pull/1631)

src/dynamic/resolve.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,17 @@ pub(crate) async fn resolve_container(
5252
fn collect_typename_field<'a>(
5353
fields: &mut Vec<BoxFieldFuture<'a>>,
5454
object: &'a Object,
55-
ctx: &ContextSelectionSet<'a>,
5655
field: &'a Positioned<Field>,
5756
) {
58-
if matches!(
59-
ctx.schema_env.registry.introspection_mode,
60-
IntrospectionMode::Enabled | IntrospectionMode::IntrospectionOnly
61-
) && matches!(
62-
ctx.query_env.introspection_mode,
63-
IntrospectionMode::Enabled | IntrospectionMode::IntrospectionOnly,
64-
) {
65-
fields.push(
66-
async move {
67-
Ok((
68-
field.node.response_key().node.clone(),
69-
Value::from(object.name.as_str()),
70-
))
71-
}
72-
.boxed(),
73-
)
74-
} else {
75-
fields
76-
.push(async move { Ok((field.node.response_key().node.clone(), Value::Null)) }.boxed())
77-
}
57+
fields.push(
58+
async move {
59+
Ok((
60+
field.node.response_key().node.clone(),
61+
Value::from(object.name.as_str()),
62+
))
63+
}
64+
.boxed(),
65+
)
7866
}
7967

8068
fn collect_schema_field<'a>(
@@ -308,7 +296,7 @@ fn collect_fields<'a>(
308296
match &selection.node {
309297
Selection::Field(field) => {
310298
if field.node.name.node == "__typename" {
311-
collect_typename_field(fields, object, ctx, field);
299+
collect_typename_field(fields, object, field);
312300
continue;
313301
}
314302

0 commit comments

Comments
 (0)