You are here

public function QueryConnection::items in GraphQL 8.4

Return value

array|\GraphQL\Deferred

File

examples/graphql_example/src/Wrappers/QueryConnection.php, line 39

Class

QueryConnection
Helper class that wraps entity queries.

Namespace

Drupal\graphql_examples\Wrappers

Code

public function items() {
  $result = $this->query
    ->execute();
  if (empty($result)) {
    return [];
  }
  $buffer = \Drupal::service('graphql.buffer.entity');
  $callback = $buffer
    ->add($this->query
    ->getEntityTypeId(), array_values($result));
  return new Deferred(function () use ($callback) {
    return $callback();
  });
}