Removing data elements from response if the error throwing

This commit is contained in:
Ilya Shaydullin 2018-05-07 17:01:18 +07:00
parent ec0985619f
commit c7f114d90b
2 changed files with 4 additions and 4 deletions

View File

@ -311,7 +311,10 @@ class Executor
return null; return null;
}) })
->then(function ($data) { ->then(function ($data) {
return new ExecutionResult((array) $data, $this->exeContext->errors); if ($data === null){
$data = (array) $data;
}
return new ExecutionResult($data, $this->exeContext->errors);
}); });
} }

View File

@ -732,7 +732,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
'; ';
$expected = [ $expected = [
'data' => null,
'errors' => [ 'errors' => [
FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(2, 17)]) FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(2, 17)])
] ]
@ -750,7 +749,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
$ast = Parser::parse($doc); $ast = Parser::parse($doc);
$expected = [ $expected = [
'data' => null,
'errors' => [ 'errors' => [
FormattedError::create($this->nonNullPromiseError->getMessage(), [new SourceLocation(2, 17)]), FormattedError::create($this->nonNullPromiseError->getMessage(), [new SourceLocation(2, 17)]),
] ]
@ -789,7 +787,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
$ast = Parser::parse($doc); $ast = Parser::parse($doc);
$expected = [ $expected = [
'data' => null,
'errors' => [ 'errors' => [
[ [
'debugMessage' => 'Cannot return null for non-nullable field DataType.nonNullPromise.', 'debugMessage' => 'Cannot return null for non-nullable field DataType.nonNullPromise.',