You are here

public function EntityBuffer::add in GraphQL 8.4

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

Add an item to the buffer.

Parameters

string $type: The entity type of the given entity ids.

array|int|string $id: The entity id(s) to load.

Return value

\Closure The callback to invoke to load the result for this buffer item.

File

src/GraphQL/Buffers/EntityBuffer.php, line 40

Class

EntityBuffer
Collects entity IDs per entity type and loads them all at once in the end.

Namespace

Drupal\graphql\GraphQL\Buffers

Code

public function add($type, $id) {
  $item = new \ArrayObject([
    'type' => $type,
    'id' => $id,
  ]);
  return $this
    ->createBufferResolver($item);
}