protected function EntityReferenceQuery::getQueryContext in GraphQL 8.3
Retrieves an arbitrary value to write into the query metadata.
Parameters
mixed $value: The parent value.
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
mixed The query context.
Overrides EntityQuery::getQueryContext
File
- modules/
graphql_core/ src/ Plugin/ GraphQL/ Fields/ EntityReference/ EntityReferenceQuery.php, line 61
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
protected function getQueryContext($value, array $args, ResolveContext $context, ResolveInfo $info) {
$context = parent::getQueryContext($value, $args, $context, $info);
// Add the target field condition to the query.
$definition = $this
->getPluginDefinition();
$field = $definition['field'];
$ids = array_map(function ($item) {
return $item['target_id'];
}, $value
->get($field)
->getValue());
return [
'ids' => $ids,
] + $context;
}