gql query alltags

This commit is contained in:
2021-04-08 19:55:16 +02:00
parent be46c004ad
commit 5322021d28
2 changed files with 20 additions and 0 deletions
@@ -46,6 +46,10 @@ extend type Query {
famille(id: Int!): Taxoterm
}
extend type Query {
alltags: [Taxoterm]
}
extend type Query {
tag(id: Int!): Taxoterm
}
@@ -815,6 +815,22 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
// |_|\__,_\__, |
// |___/
protected function addTaxoterm(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
$registry->addFieldResolver('Query', 'alltags',
$builder->compose(
$builder->callback(function($parent, $arg){
$entity_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$query = $entity_storage->getQuery()
->condition('vid', ['tags', 'tag_prod'], 'IN')
->accessCheck(TRUE);
$results = $query->execute();
return $results;
}),
$builder->produce('entity_load_multiple')
->map('type', $builder->fromValue('taxonomy_term'))
->map('ids', $builder->fromParent())
)
);
$registry->addFieldResolver('Query', 'tag',
$builder->produce('entity_load')
->map('type', $builder->fromValue('taxonomy_term'))