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().
Tags
Interfaces, Classes and Traits
- JsonSerializable
Table of Contents
- $data : array<string|int, mixed>|null
- Data collected from resolvers during query execution.
- $errors : array<string|int, mixed>
- Errors registered during query execution.
- $extensions : array<string|int, mixed>|null
- User-defined serializable array of extensions included in serialized result.
- $errorFormatter : callable|null
- $errorsHandler : callable|null
- __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 Automattic\WooCommerce\Vendor\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>|null
$data
= null
$errors
Errors registered during query execution.
public
array<string|int, mixed>
$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>|null
$extensions
= null
$errorFormatter
private
callable|null
$errorFormatter
Tags
$errorsHandler
private
callable|null
$errorsHandler
Tags
Methods
__construct()
public
__construct([array<string, mixed>|null $data = null ][, array<int, Error> $errors = [] ][, array<string, mixed> $extensions = [] ]) : mixed
Parameters
- $data : array<string, mixed>|null = null
- $errors : array<int, Error> = []
- $extensions : array<string, mixed> = []
Return values
mixed —jsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —setErrorFormatter()
Define custom error formatting (must conform to http://facebook.github.io/graphql/#sec-Errors).
public
setErrorFormatter(callable|null $errorFormatter) : self
Expected signature is: function (Automattic\WooCommerce\Vendor\GraphQL\Error\Error $error): array
Default formatter is "Automattic\WooCommerce\Vendor\GraphQL\Error\FormattedError::createFromException"
Expected returned value must be an array: array( 'message' => 'errorMessage', // ... other keys );
Parameters
- $errorFormatter : callable|null
Tags
Return values
self —setErrorsHandler()
Define custom logic for error handling (filtering, logging, etc).
public
setErrorsHandler(callable|null $errorsHandler) : self
Expected handler signature is: fn (array $errors, callable $formatter): array
Default handler is: fn (array $errors, callable $formatter): array => array_map($formatter, $errors)
Parameters
- $errorsHandler : callable|null
Tags
Return values
self —toArray()
Converts Automattic\WooCommerce\Vendor\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 \Automattic\WooCommerce\Vendor\GraphQL\Error\DebugFlag
Parameters
- $debug : int = DebugFlag::NONE
