protected function DataProducerProxy::resolveCached in GraphQL 8.4
Try to return a value from cache, otherwise invoke data producer.
Parameters
\Drupal\graphql\Plugin\DataProducerPluginCachingInterface $plugin:
\Drupal\graphql\GraphQL\Execution\ResolveContext $context:
\Drupal\graphql\GraphQL\Execution\FieldContext $field:
Return value
mixed
1 call to DataProducerProxy::resolveCached()
- DataProducerProxy::resolve in src/
Plugin/ GraphQL/ DataProducer/ DataProducerProxy.php - Resolve field value.
File
- src/
Plugin/ GraphQL/ DataProducer/ DataProducerProxy.php, line 253
Class
- DataProducerProxy
- A proxy class that lazy resolves data producers and has a result cache.
Namespace
Drupal\graphql\Plugin\GraphQL\DataProducerCode
protected function resolveCached(DataProducerPluginCachingInterface $plugin, ResolveContext $context, FieldContext $field) {
$prefix = $this
->edgeCachePrefix($plugin);
if ($cache = $this
->cacheRead($prefix)) {
list($value, $metadata) = $cache;
$field
->addCacheableDependency($metadata);
return $value;
}
$output = $this
->resolveUncached($plugin, $context, $field);
return DeferredUtility::applyFinally($output, function ($value) use ($field, $prefix) {
$this
->cacheWrite($prefix, $value, $field);
});
}