You are here

public function RequestController::handleRequest in GraphQL 8.4

Same name and namespace in other branches
  1. 8 src/Controller/RequestController.php \Drupal\graphql\Controller\RequestController::handleRequest()
  2. 8.2 src/Controller/RequestController.php \Drupal\graphql\Controller\RequestController::handleRequest()
  3. 8.3 src/Controller/RequestController.php \Drupal\graphql\Controller\RequestController::handleRequest()

Handles graphql requests.

Parameters

\Drupal\graphql\Entity\ServerInterface $graphql_server: The server instance.

\GraphQL\Server\OperationParams|\GraphQL\Server\OperationParams[] $operations: The graphql operation(s) to execute.

Return value

\Drupal\Core\Cache\CacheableJsonResponse The JSON formatted response.

Throws

\Exception

File

src/Controller/RequestController.php, line 57

Class

RequestController
The main GraphQL request handler that will forward to the responsible server.

Namespace

Drupal\graphql\Controller

Code

public function handleRequest(ServerInterface $graphql_server, $operations) {
  if (is_array($operations)) {
    return $this
      ->handleBatch($graphql_server, $operations);
  }

  /** @var \GraphQL\Server\OperationParams $operations */
  return $this
    ->handleSingle($graphql_server, $operations);
}