You are here

public function EntityReferenceReverse::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/EntityReference/EntityReferenceReverse.php, line 39

Class

EntityReferenceReverse
Plugin annotation @GraphQLField( id = "entity_reference_reverse", secure = true, type = "EntityQueryResult!", arguments = { "filter" = "EntityQueryFilterInput", "sort" = "[EntityQuerySortInput]", "offset" = { "type" =…

Namespace

Drupal\graphql_core\Plugin\GraphQL\Fields\EntityReference

Code

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

    // Add the target field condition to the query.
    $definition = $this
      ->getPluginDefinition();
    $field = $definition['field'];
    $query
      ->condition($field, $value
      ->id());
    return $query;
  }
}