created textsdepart graphql query

This commit is contained in:
2021-02-12 14:27:21 +01:00
parent c60bd6d8c9
commit 2fb90cb0cb
2 changed files with 32 additions and 0 deletions
@@ -2,6 +2,10 @@
# route(path: String!): NodeInterface
# }
extend type Query {
textsdepart: [Textref]
}
extend type Query {
textref(id: Int!): Textref
}
@@ -29,6 +29,8 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
$this->addRouteResolver($registry, $builder);
$this->addTextsdepart($registry, $builder);
$this->addTextref($registry, $builder);
$this->addTextprod($registry, $builder);
@@ -104,6 +106,32 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
}
// _____ _ ___ _
// |_ _|____ _| |_ ___ | \ ___ _ __ __ _ _ _| |_
// | |/ -_) \ / _(_-< | |) / -_) '_ \/ _` | '_| _|
// |_|\___/_\_\\__/__/ |___/\___| .__/\__,_|_| \__|
// |_|
protected function addTextsdepart(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
$registry->addFieldResolver('Query', 'textsdepart',
$builder->compose(
$builder->callback(function($parent, $arg){
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
$query = $entity_storage->getQuery()
->condition('type', 'texte')
->condition('field_famille', 9)
->accessCheck(TRUE);
$results = $query->execute();
return $results;
}),
$builder->produce('entity_load_multiple')
->map('type', $builder->fromValue('node'))
->map('ids', $builder->fromParent())
)
);
}
// _____ _ __
// |_ _|____ _| |_ _ _ ___ / _|
// | |/ -_) \ / _| '_/ -_) _|