You are here

class Response in GraphQL 8.4

Base class for responses containing the violations.

Hierarchy

Expanded class hierarchy of Response

3 files declare their use of Response
ArticleResponse.php in examples/graphql_composable/src/GraphQL/Response/ArticleResponse.php
ArticleResponse.php in examples/graphql_composable/src/Wrappers/Response/ArticleResponse.php
PasswordReset.php in src/Plugin/GraphQL/DataProducer/User/PasswordReset.php
1 string reference to 'Response'
ComposableSchemaExampleExtension::registerResolvers in examples/graphql_composable/src/Plugin/GraphQL/SchemaExtension/ComposableSchemaExampleExtension.php
Registers type and field resolvers in the shared registry.

File

src/GraphQL/Response/Response.php, line 10

Namespace

Drupal\graphql\GraphQL\Response
View source
class Response implements ResponseInterface {

  /**
   * List of violations.
   *
   * @var array
   */
  protected $violations = [];

  /**
   * {@inheritdoc}
   */
  public function addViolation($message, array $properties = []) : void {
    $properties['message'] = (string) $message;
    $this->violations[] = $properties;
  }

  /**
   * {@inheritdoc}
   */
  public function addViolations(array $messages, array $properties = []) : void {
    foreach ($messages as $message) {
      $this
        ->addViolation($message, $properties);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getViolations() : array {
    return $this->violations;
  }

  /**
   * {@inheritdoc}
   */
  public function mergeViolations(ResponseInterface $source) : void {
    $this->violations = array_merge($this->violations, $source
      ->getViolations());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Response::$violations protected property List of violations.
Response::addViolation public function Adds the violation. Overrides ResponseInterface::addViolation
Response::addViolations public function Adds multiple violations. Overrides ResponseInterface::addViolations
Response::getViolations public function Gets the violations. Overrides ResponseInterface::getViolations
Response::mergeViolations public function Adds the violations from another response to this response. Overrides ResponseInterface::mergeViolations