You are here

protected function BufferBase::resolveItem in GraphQL 8.4

Same name and namespace in other branches
  1. 8.3 src/GraphQL/Buffers/BufferBase.php \Drupal\graphql\GraphQL\Buffers\BufferBase::resolveItem()

Returns the result of the given item after processing the buffer if needed.

Parameters

object $item: The buffer item to retrieve the result for.

\SplObjectStorage $buffer: The buffer.

\SplObjectStorage $result: The result set.

Return value

mixed The result of resolving the given buffer item.

1 call to BufferBase::resolveItem()
BufferBase::createResolver in src/GraphQL/Buffers/BufferBase.php
Creates a callback to invoke to load the result for this buffer item.

File

src/GraphQL/Buffers/BufferBase.php, line 96

Class

BufferBase
Base class for field buffering services.

Namespace

Drupal\graphql\GraphQL\Buffers

Code

protected function resolveItem($item, \SplObjectStorage $buffer, \SplObjectStorage $result) {
  if ($buffer
    ->contains($item)) {
    $results = $this
      ->resolveBuffer($buffer);

    // Remove the resolved items from the buffer and add them to the results.
    $buffer
      ->removeAll($results);
    $result
      ->addAll($results);
  }
  if ($result
    ->contains($item)) {
    return $result[$item];
  }
  throw new \LogicException('Failed to resolve item.');
}