You are here

public function EntityRevisions::getBaseQuery in GraphQL 8.3

Create the basic entity query for the plugin's entity type.

Parameters

mixed $value: The parent entity type.

array $args: The field arguments array.

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

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

Return value

\Drupal\Core\Entity\Query\QueryInterface|null The entity query object.

Overrides EntityQuery::getBaseQuery

File

modules/graphql_core/src/Plugin/GraphQL/Fields/Entity/EntityRevisions.php, line 37

Class

EntityRevisions
Plugin annotation @GraphQLField( id = "entity_revisions", name = "entityRevisions", secure = true, parents = {"EntityRevisionable"}, type = "EntityQueryResult!", arguments = { "filter" = "EntityQueryFilterInput", "sort" =…

Namespace

Drupal\graphql_core\Plugin\GraphQL\Fields\Entity

Code

public function getBaseQuery($value, array $args, ResolveContext $context, ResolveInfo $info) {
  if ($value instanceof EntityInterface) {
    $query = parent::getBaseQuery($value, $args, $context, $info);

    // Add the entity id as a filter condition.
    $key = $value
      ->getEntityType()
      ->getKey('id');
    $query
      ->condition($key, $value
      ->id());

    // Mark the query as a revision query.
    return $this
      ->applyRevisionsMode($query, 'all');
  }
}