From 63b04df6ef1b774780d6ef94c005bb1ddcf277ec Mon Sep 17 00:00:00 2001 From: Ilya Shaydullin Date: Mon, 7 May 2018 17:01:18 +0700 Subject: [PATCH] Removing data elements from response if the error throwing (cherry picked from commit c7f114d) --- src/Executor/Executor.php | 5 ++++- tests/Executor/NonNullTest.php | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index f665be8..702e033 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -311,7 +311,10 @@ class Executor return null; }) ->then(function ($data) { - return new ExecutionResult((array) $data, $this->exeContext->errors); + if ($data === null){ + $data = (array) $data; + } + return new ExecutionResult($data, $this->exeContext->errors); }); } diff --git a/tests/Executor/NonNullTest.php b/tests/Executor/NonNullTest.php index 9c5fbfe..bb18ac2 100644 --- a/tests/Executor/NonNullTest.php +++ b/tests/Executor/NonNullTest.php @@ -732,7 +732,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase '; $expected = [ - 'data' => null, 'errors' => [ FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(2, 17)]) ] @@ -750,7 +749,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase $ast = Parser::parse($doc); $expected = [ - 'data' => null, 'errors' => [ FormattedError::create($this->nonNullPromiseError->getMessage(), [new SourceLocation(2, 17)]), ] @@ -789,7 +787,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase $ast = Parser::parse($doc); $expected = [ - 'data' => null, 'errors' => [ [ 'debugMessage' => 'Cannot return null for non-nullable field DataType.nonNullPromise.',