Automattic\WooCommerce\Vendor\GraphQL\Executor
ExecutionResult::toArray
Converts Automattic\WooCommerce\Vendor\GraphQL query result to spec-compliant serializable array using provided errors handler and formatter.
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
Method of the class: ExecutionResult{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ExecutionResult = new ExecutionResult(); $ExecutionResult->toArray( $debug ): array;
- $debug(int)
- .
Default:DebugFlag::NONE
ExecutionResult::toArray() ExecutionResult::toArray code WC 10.8.1
public function toArray(int $debug = DebugFlag::NONE): array
{
$result = [];
if ($this->errors !== []) {
$errorsHandler = $this->errorsHandler
?? static fn (array $errors, callable $formatter): array => array_map($formatter, $errors);
/** @phpstan-var SerializableErrors */
$handledErrors = $errorsHandler(
$this->errors,
FormattedError::prepareFormatter($this->errorFormatter, $debug)
);
// While we know that there were errors initially, they might have been discarded
if ($handledErrors !== []) {
$result['errors'] = $handledErrors;
}
}
if ($this->data !== null) {
$result['data'] = $this->data;
}
if ($this->extensions !== null && $this->extensions !== []) {
$result['extensions'] = $this->extensions;
}
return $result;
}