public function BufferBase::createBufferResolver in GraphQL 8.3
Same name and namespace in other branches
- 8.4 src/GraphQL/Buffers/BufferBase.php \Drupal\graphql\GraphQL\Buffers\BufferBase::createBufferResolver()
Helper function to create a resolver for a singular buffer.
Parameters
object $item: The item to add to the buffer.
Return value
\Closure The callback to invoke to load the result for this buffer item.
2 calls to BufferBase::createBufferResolver()
- EntityBuffer::add in src/
GraphQL/ Buffers/ EntityBuffer.php - Add an item to the buffer.
- SubRequestBuffer::add in src/
GraphQL/ Buffers/ SubRequestBuffer.php - Add an item to the buffer.
File
- src/
GraphQL/ Buffers/ BufferBase.php, line 43
Class
- BufferBase
- Base class for field buffering services.
Namespace
Drupal\graphql\GraphQL\BuffersCode
public function createBufferResolver($item) {
$bufferId = $this
->getBufferId($item);
if (!isset($this->buffers[$bufferId])) {
$this->buffers[$bufferId] = new \SplObjectStorage();
}
if (!isset($this->results[$bufferId])) {
$this->results[$bufferId] = new \SplObjectStorage();
}
// Add the created item to the buffer.
$this->buffers[$bufferId]
->attach($item, $item);
// Return a callback that can be used to resolve the buffer item.
return $this
->createResolver($item, $this->buffers[$bufferId], $this->results[$bufferId]);
}