diff --git a/CHANGELOG.md b/CHANGELOG.md index 53d35bbd5..d3b02e694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ You can find and compare releases at the [GitHub release page](https://github.co ## Unreleased +## v15.0.2 + +### Fixed + +- Fix `QueryPlan` when querying `__typename` on a `union` type + ## v15.0.1 ### Fixed diff --git a/src/Type/Definition/QueryPlan.php b/src/Type/Definition/QueryPlan.php index 39baa653d..79199ecce 100644 --- a/src/Type/Definition/QueryPlan.php +++ b/src/Type/Definition/QueryPlan.php @@ -152,14 +152,14 @@ private function analyzeSelectionSet(SelectionSetNode $selectionSet, Type $paren $implementors = []; foreach ($selectionSet->selections as $selectionNode) { if ($selectionNode instanceof FieldNode) { - assert($parentType instanceof HasFieldsType, 'ensured by query validation'); - $fieldName = $selectionNode->name->value; if ($fieldName === Introspection::TYPE_NAME_FIELD_NAME) { continue; } + assert($parentType instanceof HasFieldsType, 'ensured by query validation and the check above which excludes union types'); + $type = $parentType->getField($fieldName); $selectionType = $type->getType();