You are here

protected function RequestController::handleBatch in GraphQL 8.3

Same name and namespace in other branches
  1. 8.4 src/Controller/RequestController.php \Drupal\graphql\Controller\RequestController::handleBatch()

Parameters

$schema:

$operations:

array $globals:

Return value

\Drupal\Core\Cache\CacheableJsonResponse

Throws

\Drupal\Component\Plugin\Exception\PluginException

1 call to RequestController::handleBatch()
RequestController::handleRequest in src/Controller/RequestController.php
Handles graphql requests.

File

src/Controller/RequestController.php, line 96

Class

RequestController
Handles GraphQL requests.

Namespace

Drupal\graphql\Controller

Code

protected function handleBatch($schema, $operations) {
  $result = $this->processor
    ->processQuery($schema, $operations);
  $response = new CacheableJsonResponse($result);

  // In case of a batch request, the result is an array.
  $dependencies = is_array($operations) ? $result : [
    $result,
  ];
  foreach ($dependencies as $dependency) {
    $response
      ->addCacheableDependency($dependency);
  }
  return $response;
}