Skip to content

Commit

Permalink
Fix QueryPlan when querying __typename on a union type (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia authored Feb 2, 2023
1 parent 4af8a10 commit ff5bc60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Definition/QueryPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit ff5bc60

Please sign in to comment.