You are here

protected function Executor::cachePrefix in GraphQL 8.4

Calculates the cache prefix from context for the current query.

Return value

string

1 call to Executor::cachePrefix()
Executor::doExecute in src/GraphQL/Execution/Executor.php

File

src/GraphQL/Execution/Executor.php, line 292

Class

Executor
Executes GraphQL queries with cache lookup.

Namespace

Drupal\graphql\GraphQL\Execution

Code

protected function cachePrefix() {

  // Sorting the variables and extensions will cause fewer cache vectors.
  // @todo Should we try to sort these recursively?
  $variables = $this->variables ?: [];
  ksort($variables);

  // @todo Should we submit a pull request to also pass the extensions in the
  // executor?
  $extensions = $this->context
    ->getOperation()->extensions ?: [];
  ksort($extensions);
  $hash = hash('sha256', serialize([
    'query' => DocumentSerializer::serializeDocument($this->document),
    'variables' => $variables,
    'extensions' => $extensions,
  ]));
  return $hash;
}