You are here

trait DataProducerPluginCachingTrait in GraphQL 8.4

Cache prefix implementation for data producers.

Hierarchy

File

src/Plugin/GraphQL/DataProducer/DataProducerPluginCachingTrait.php, line 10

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer
View source
trait DataProducerPluginCachingTrait {

  /**
   * {@inheritdoc}
   */
  public function edgeCachePrefix() : string {
    $contexts = array_map(function ($context) {
      if ($context instanceof EntityInterface) {
        return $context
          ->uuid();
      }
      return $context;
    }, $this
      ->getContextValues());
    return hash('sha256', serialize($contexts));
  }

  /**
   * {@inheritdoc}
   */
  public abstract function getContextValues();

}

Members