mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-20 06:13:13 +03:00
39 lines
658 B
PHP
39 lines
658 B
PHP
|
<?php
|
||
|
namespace GraphQL\Executor;
|
||
|
|
||
|
use GraphQL\Error;
|
||
|
|
||
|
class ExecutionResult
|
||
|
{
|
||
|
/**
|
||
|
* @var array
|
||
|
*/
|
||
|
public $data;
|
||
|
|
||
|
/**
|
||
|
* @var Error[]
|
||
|
*/
|
||
|
public $errors;
|
||
|
|
||
|
/**
|
||
|
* @param array $data
|
||
|
* @param array $errors
|
||
|
*/
|
||
|
public function __construct(array $data = null, array $errors = [])
|
||
|
{
|
||
|
$this->data = $data;
|
||
|
$this->errors = $errors;
|
||
|
}
|
||
|
|
||
|
public function toArray()
|
||
|
{
|
||
|
$result = ['data' => $this->data];
|
||
|
|
||
|
if (!empty($this->errors)) {
|
||
|
$result['errors'] = array_map(['GraphQL\Error', 'formatError'], $this->errors);
|
||
|
}
|
||
|
|
||
|
return $result;
|
||
|
}
|
||
|
}
|