Automattic\WooCommerce\Vendor\GraphQL\Server

Helper::executeBatch │ public │ WC 1.0

Executes batched Automattic\WooCommerce\Vendor\GraphQL operations with shared promise queue (thus, effectively batching deferreds|promises of all queries at once).

Method of the class: Helper{}

No Hooks.

Returns

array<int, ExecutionResult>|Promise.

Usage

$Helper = new Helper();
$Helper->executeBatch( $config, $operations );
$config(ServerConfig) (required)
.
$operations(array) (required)
.

Helper::executeBatch() code WC 11.1.2

public function executeBatch(ServerConfig $config, array $operations)
{
    $promiseAdapter = $config->getPromiseAdapter() ?? Executor::getDefaultPromiseAdapter();

    $result = [];
    foreach ($operations as $operation) {
        $result[] = $this->promiseToExecuteOperation($promiseAdapter, $config, $operation, true);
    }

    $result = $promiseAdapter->all($result);

    // Wait for promised results when using sync promises
    if ($promiseAdapter instanceof SyncPromiseAdapter) {
        $result = $promiseAdapter->wait($result);
    }

    return $result;
}