Skip to content

Commit dff830f

Browse files
authored
Add support for __typename field in QueryPlan (#831)
1 parent 045bd4d commit dff830f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Type/Definition/QueryPlan.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use GraphQL\Language\AST\FragmentSpreadNode;
1212
use GraphQL\Language\AST\InlineFragmentNode;
1313
use GraphQL\Language\AST\SelectionSetNode;
14+
use GraphQL\Type\Introspection;
1415
use GraphQL\Type\Schema;
1516

1617
use function array_diff_key;
@@ -168,7 +169,12 @@ private function analyzeSelectionSet(SelectionSetNode $selectionSet, Type $paren
168169
$implementors = [];
169170
foreach ($selectionSet->selections as $selectionNode) {
170171
if ($selectionNode instanceof FieldNode) {
171-
$fieldName = $selectionNode->name->value;
172+
$fieldName = $selectionNode->name->value;
173+
174+
if ($fieldName === Introspection::TYPE_NAME_FIELD_NAME) {
175+
continue;
176+
}
177+
172178
$type = $parentType->getField($fieldName);
173179
$selectionType = $type->getType();
174180

tests/Type/QueryPlanTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function testQueryPlan(): void
7272
$doc = '
7373
query Test {
7474
article {
75+
__typename
7576
author {
7677
name
7778
pic(width: 100, height: 200) {

0 commit comments

Comments
 (0)