You are here

class OperationEvent in GraphQL 8.4

Represents an event that is triggered before and after a GraphQL operation.

Hierarchy

  • class \Drupal\graphql\Event\OperationEvent extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of OperationEvent

2 files declare their use of OperationEvent
Executor.php in src/GraphQL/Execution/Executor.php
OperationSubscriber.php in src/EventSubscriber/OperationSubscriber.php

File

src/Event/OperationEvent.php, line 12

Namespace

Drupal\graphql\Event
View source
class OperationEvent extends Event {

  /**
   * Event fired before an operation is executed.
   *
   * @var string
   */
  const GRAPHQL_OPERATION_BEFORE = 'graphql.operation.before';

  /**
   * Event fired after an operation was executed.
   *
   * @var string
   */
  const GRAPHQL_OPERATION_AFTER = 'graphql.operation.after';

  /**
   * Result of the query execution.
   *
   * @var \GraphQL\Executor\ExecutionResult
   */
  protected $result;

  /**
   * Resolver context used for the query.
   *
   * @var \Drupal\graphql\GraphQL\Execution\ResolveContext
   */
  protected $context;

  /**
   * OperationEvent constructor.
   *
   * @param \Drupal\graphql\GraphQL\Execution\ResolveContext $context
   * @param \GraphQL\Executor\ExecutionResult $result
   */
  public function __construct(ResolveContext $context, ExecutionResult $result = NULL) {
    $this->context = $context;
    $this->result = $result;
  }

  /**
   * Returns the execution result.
   *
   * @return \GraphQL\Executor\ExecutionResult
   */
  public function getResult() {
    return $this->result;
  }

  /**
   * Returns the resolver context.
   *
   * @return \Drupal\graphql\GraphQL\Execution\ResolveContext
   */
  public function getContext() {
    return $this->context;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OperationEvent::$context protected property Resolver context used for the query.
OperationEvent::$result protected property Result of the query execution.
OperationEvent::getContext public function Returns the resolver context.
OperationEvent::getResult public function Returns the execution result.
OperationEvent::GRAPHQL_OPERATION_AFTER constant Event fired after an operation was executed.
OperationEvent::GRAPHQL_OPERATION_BEFORE constant Event fired before an operation is executed.
OperationEvent::__construct public function OperationEvent constructor.