ExecutionResult
in package
implements
JsonSerializable
Returned after [query execution](executing-queries.md).
Represents both - result of successful execution and of a failed one
(with errors collected in errors
prop)
Could be converted to spec-compliant
serializable array using toArray()
Interfaces, Classes, Traits and Enums
- JsonSerializable
Table of Contents
- $data : array<string|int, mixed>
- Data collected from resolvers during query execution
- $errors : array<string|int, Error>
- Errors registered during query execution.
- $extensions : array<string|int, mixed>
- User-defined serializable array of extensions included in serialized result.
- $errorFormatter : callable
- $errorsHandler : callable
- __construct() : mixed
- jsonSerialize() : array<string|int, mixed>
- setErrorFormatter() : self
- Define custom error formatting (must conform to http://facebook.github.io/graphql/#sec-Errors)
- setErrorsHandler() : self
- Define custom logic for error handling (filtering, logging, etc).
- toArray() : array<string|int, mixed>
- Converts GraphQL query result to spec-compliant serializable array using provided errors handler and formatter.
Properties
$data
Data collected from resolvers during query execution
public
array<string|int, mixed>
$data
$errors
Errors registered during query execution.
public
array<string|int, Error>
$errors
If an error was caused by exception thrown in resolver, $error->getPrevious() would contain original exception.
$extensions
User-defined serializable array of extensions included in serialized result.
public
array<string|int, mixed>
$extensions
Conforms to
$errorFormatter
private
callable
$errorFormatter
$errorsHandler
private
callable
$errorsHandler
Methods
__construct()
public
__construct([array<string|int, mixed> $data = null ][, array<string|int, Error> $errors = [] ][, array<string|int, mixed> $extensions = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = null
- $errors : array<string|int, Error> = []
- $extensions : array<string|int, mixed> = []
Return values
mixed —jsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —setErrorFormatter()
Define custom error formatting (must conform to http://facebook.github.io/graphql/#sec-Errors)
public
setErrorFormatter(callable $errorFormatter) : self
Expected signature is: function (GraphQL\Error\Error $error): array
Default formatter is "GraphQL\Error\FormattedError::createFromException"
Expected returned value must be an array: array( 'message' => 'errorMessage', // ... other keys );
Parameters
- $errorFormatter : callable
Return values
self —setErrorsHandler()
Define custom logic for error handling (filtering, logging, etc).
public
setErrorsHandler(callable $handler) : self
Expected handler signature is: function (array $errors, callable $formatter): array
Default handler is: function (array $errors, callable $formatter) { return array_map($formatter, $errors); }
Parameters
- $handler : callable
Return values
self —toArray()
Converts GraphQL query result to spec-compliant serializable array using provided errors handler and formatter.
public
toArray([int $debug = DebugFlag::NONE ]) : array<string|int, mixed>
If debug argument is passed, output of error formatter is enriched which debugging information ("debugMessage", "trace" keys depending on flags).
$debug argument must sum of flags from @see \GraphQL\Error\DebugFlag
Parameters
- $debug : int = DebugFlag::NONE