From 83e33659cb7484bcfc7267fffe7771f9ac46d393 Mon Sep 17 00:00:00 2001 From: vladar Date: Sun, 6 Sep 2015 15:48:16 +0600 Subject: [PATCH] Do not mess with original value in executor. Copy it instead. --- src/Executor/Executor.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 5cb5af6..3b7e473 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -193,7 +193,6 @@ class Executor * @param ExecutionContext $exeContext * @param ObjectType $parentType * @param $sourceList - * @param $sourceIsList * @param $fields * @return array * @throws Error @@ -598,8 +597,11 @@ class Executor $resultTypeMap = []; $typeNameMap = []; $cursors = []; + $copied = []; foreach ($result as $index => $item) { + $copied[$index] = $item; + if (null !== $item) { $objectType = $itemType->getObjectType($item, $info); @@ -607,7 +609,7 @@ class Executor $exeContext->addError(new Error( "Runtime Object type \"$objectType\" is not a possible type for \"$itemType\"." )); - $result[$index] = null; + $copied[$index] = null; } else { $listPerObjectType[$objectType->name][] = $item; $resultTypeMap[$index] = $objectType->name; @@ -626,7 +628,7 @@ class Executor // Restore order: $completed = []; - foreach ($result as $index => $item) { + foreach ($copied as $index => $item) { if (null === $item) { // Complete nulls separately $completed[] = self::completeValueCatchingError($exeContext, $itemType, $fieldASTs, $info, $item);