You are here

class QueryResult in GraphQL 8.3

Hierarchy

Expanded class hierarchy of QueryResult

1 file declares its use of QueryResult
QueryResultAssertionTrait.php in tests/src/Traits/QueryResultAssertionTrait.php

File

src/GraphQL/Execution/QueryResult.php, line 10

Namespace

Drupal\graphql\GraphQL\Execution
View source
class QueryResult extends ExecutionResult implements RefinableCacheableDependencyInterface {
  use RefinableCacheableDependencyTrait;

  /**
   * QueryResult constructor.
   *
   * @param array $data
   *   Result data.
   * @param array $errors
   *   Errors collected during execution.
   * @param array $extensions
   *   User specified array of extensions.
   * @param \Drupal\Core\Cache\CacheableDependencyInterface $metadata
   *   The cache metadata collected during query execution.
   */
  public function __construct(array $data = null, array $errors = [], array $extensions = [], CacheableDependencyInterface $metadata = NULL) {
    $this->data = $data;
    $this->errors = $errors;
    $this->extensions = $extensions;

    // If no cache metadata was given, assume this result is not cacheable.
    $this
      ->addCacheableDependency($metadata);
  }

  /**
   * Don't serialize errors, since they might contain closures.
   *
   * @return string[]
   *   The property names to serialize.
   */
  public function __sleep() {

    // TODO: Find a better way to solve this.
    return array_filter(array_keys(get_object_vars($this)), function ($prop) {
      return $prop != 'errors';
    });
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function 3
CacheableDependencyTrait::getCacheMaxAge public function 3
CacheableDependencyTrait::getCacheTags public function 3
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
QueryResult::__construct public function QueryResult constructor.
QueryResult::__sleep public function Don't serialize errors, since they might contain closures.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function