protected function EntityQueryExclusive::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/ EntityQueryExclusive.php, line 48
Class
- EntityQueryExclusive
- Query entities of the same type without the context's entity.
Namespace
Drupal\graphql_core\Plugin\GraphQL\Fields\EntityCode
protected function getBaseQuery($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof ContentEntityInterface) {
$type = $value
->getEntityType();
$id = $type
->getKey('id');
// Filter out the current entity.
$query = parent::getBaseQuery($value, $args, $context, $info);
$query
->condition($id, $value
->id(), '<>');
if (array_key_exists('bundles', $args)) {
$query = $this
->applyBundleMode($query, $value, $args['bundles']);
}
return $query;
}
}