From c7f114d90bc57856525955889fc0c4649dbcd32b 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 --- 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 fac9553..655c6fc 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 1519f78..70b88c3 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.',