Skip to content

Commit 83e3365

Browse files
committed
Do not mess with original value in executor. Copy it instead.
1 parent 913caf3 commit 83e3365

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Executor/Executor.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ private static function getOperationRootType(Schema $schema, OperationDefinition
193193
* @param ExecutionContext $exeContext
194194
* @param ObjectType $parentType
195195
* @param $sourceList
196-
* @param $sourceIsList
197196
* @param $fields
198197
* @return array
199198
* @throws Error
@@ -598,16 +597,19 @@ private static function completeValue(ExecutionContext $exeContext, Type $return
598597
$resultTypeMap = [];
599598
$typeNameMap = [];
600599
$cursors = [];
600+
$copied = [];
601601

602602
foreach ($result as $index => $item) {
603+
$copied[$index] = $item;
604+
603605
if (null !== $item) {
604606
$objectType = $itemType->getObjectType($item, $info);
605607

606608
if ($objectType && !$itemType->isPossibleType($objectType)) {
607609
$exeContext->addError(new Error(
608610
"Runtime Object type \"$objectType\" is not a possible type for \"$itemType\"."
609611
));
610-
$result[$index] = null;
612+
$copied[$index] = null;
611613
} else {
612614
$listPerObjectType[$objectType->name][] = $item;
613615
$resultTypeMap[$index] = $objectType->name;
@@ -626,7 +628,7 @@ private static function completeValue(ExecutionContext $exeContext, Type $return
626628

627629
// Restore order:
628630
$completed = [];
629-
foreach ($result as $index => $item) {
631+
foreach ($copied as $index => $item) {
630632
if (null === $item) {
631633
// Complete nulls separately
632634
$completed[] = self::completeValueCatchingError($exeContext, $itemType, $fieldASTs, $info, $item);

0 commit comments

Comments
 (0)