public function EntityReferenceQuery::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/ EntityReferenceQuery.php, line 39
Class
- EntityReferenceQuery
- Plugin annotation @GraphQLField( id = "entity_reference_query", secure = true, type = "EntityQueryResult", arguments = { "filter" = "EntityQueryFilterInput", "sort" = "[EntityQuerySortInput]", "offset" = { "type" = "Int", …
Namespace
Drupal\graphql_core\Plugin\GraphQL\Fields\EntityReferenceCode
public function getBaseQuery($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof ContentEntityInterface) {
$query = parent::getBaseQuery($value, $args, $context, $info);
$metadata = $query
->getMetadata('graphql_context');
$ids = $metadata['ids'];
if (empty($ids)) {
return NULL;
}
$definition = $this
->getPluginDefinition();
$key = $definition['entity_key'];
$operator = is_array($ids) ? 'IN' : '=';
$query
->condition($key, $ids, $operator);
return $query;
}
}