You are here

protected function FieldPluginBase::getCacheDependencies in GraphQL 8.3

Retrieve the list of cache dependencies for a given value and arguments.

Parameters

array $result: The result of the field.

mixed $parent: The parent value.

array $args: The arguments passed to the field.

\Drupal\graphql\GraphQL\Execution\ResolveContext $context: The resolve context.

\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.

Return value

array A list of cacheable dependencies.

1 call to FieldPluginBase::getCacheDependencies()
FieldPluginBase::resolveDeferred in src/Plugin/GraphQL/Fields/FieldPluginBase.php
1 method overrides FieldPluginBase::getCacheDependencies()
EntityQuery::getCacheDependencies in modules/graphql_core/src/Plugin/GraphQL/Fields/EntityQuery/EntityQuery.php
Retrieve the list of cache dependencies for a given value and arguments.

File

src/Plugin/GraphQL/Fields/FieldPluginBase.php, line 253

Class

FieldPluginBase

Namespace

Drupal\graphql\Plugin\GraphQL\Fields

Code

protected function getCacheDependencies(array $result, $parent, array $args, ResolveContext $context, ResolveInfo $info) {
  $self = new CacheableMetadata();
  $definition = $this
    ->getPluginDefinition();
  if (!empty($definition['response_cache_contexts'])) {
    $self
      ->addCacheContexts($definition['response_cache_contexts']);
  }
  if (!empty($definition['response_cache_tags'])) {
    $self
      ->addCacheTags($definition['response_cache_tags']);
  }
  if (isset($definition['response_cache_max_age'])) {
    $self
      ->mergeCacheMaxAge($definition['response_cache_max_age']);
  }
  return array_merge([
    $self,
  ], array_filter($result, function ($item) {
    return $item instanceof CacheableDependencyInterface;
  }));
}