You are here

public function Server::executeOperation in GraphQL 8.4

Execute an operation on this server.

Parameters

\GraphQL\Server\OperationParams $operation:

Return value

\Drupal\graphql\GraphQL\Execution\ExecutionResult

Overrides ServerInterface::executeOperation

1 call to Server::executeOperation()
Server::executeBatch in src/Entity/Server.php
Execute multiple operations as batch on this server.

File

src/Entity/Server.php, line 165

Class

Server
The main GraphQL configuration and request entry point.

Namespace

Drupal\graphql\Entity

Code

public function executeOperation(OperationParams $operation) {
  $previous = Executor::getImplementationFactory();
  Executor::setImplementationFactory([
    \Drupal::service('graphql.executor'),
    'create',
  ]);
  try {
    $config = $this
      ->configuration();
    $result = (new Helper())
      ->executeOperation($config, $operation);

    // In case execution fails before the execution stage, we have to wrap the
    // result object here.
    if (!$result instanceof CacheableExecutionResult) {
      $result = new CacheableExecutionResult($result->data, $result->errors, $result->extensions);
      $result
        ->mergeCacheMaxAge(0);
    }
  } finally {
    Executor::setImplementationFactory($previous);
  }
  return $result;
}