You are here

protected function RequestController::handleSingle in GraphQL 8.4

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

Execute a single operation and turn that into a cacheable response.

Parameters

\Drupal\graphql\Entity\ServerInterface $server:

\GraphQL\Server\OperationParams $operation:

Return value

\Drupal\Core\Cache\CacheableJsonResponse

Throws

\Exception

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

File

src/Controller/RequestController.php, line 76

Class

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

Namespace

Drupal\graphql\Controller

Code

protected function handleSingle(ServerInterface $server, OperationParams $operation) {
  $result = $server
    ->executeOperation($operation);
  $response = new CacheableJsonResponse($result);
  $response
    ->addCacheableDependency($result);
  return $response;
}