added author, lieu & structure infos to graphql

This commit is contained in:
Bachir Soussi Chiadmi 2023-07-03 16:08:10 +02:00
parent 3073848475
commit f1ae451352
2 changed files with 118 additions and 78 deletions

View File

@ -3,6 +3,8 @@ scalar Violation
interface NodeInterface { interface NodeInterface {
id: Int! id: Int!
path: String! path: String!
created: String
changed: String
} }
type Concernement implements NodeInterface { type Concernement implements NodeInterface {
@ -11,7 +13,10 @@ type Concernement implements NodeInterface {
uuid: String! uuid: String!
bundle: String! bundle: String!
title: String! title: String!
author: String author: User
created: String
changed: String
lieu: [Taxoterm]
description: String description: String
caillou: String caillou: String
recit: Filefield recit: Filefield
@ -34,6 +39,8 @@ type Entite implements NodeInterface {
bundle: String! bundle: String!
title: String! title: String!
author: String author: String
created: String
changed: String
action: String action: String
menacemaintien: String menacemaintien: String
superposition: [Entite] superposition: [Entite]
@ -56,6 +63,8 @@ type Besoin implements NodeInterface {
id: Int! id: Int!
path: String! path: String!
author: String author: String
created: String
changed: String
description: String! description: String!
index: Int index: Int
concernement: Concernement concernement: Concernement
@ -66,6 +75,8 @@ type Reponse implements NodeInterface {
id: Int! id: Int!
path: String! path: String!
author: String author: String
created: String
changed: String
besoin: Besoin besoin: Besoin
qui: String qui: String
quoi: String quoi: String
@ -80,6 +91,8 @@ type Doleance implements NodeInterface {
bundle: String! bundle: String!
title: String! title: String!
author: String author: String
created: String
changed: String
#1 #1
leprobleme: String leprobleme: String
lenquete: String lenquete: String
@ -135,6 +148,8 @@ type Static implements NodeInterface {
title: String! title: String!
path: String! path: String!
author: String author: String
created: String
changed: String
texte: String texte: String
} }
@ -161,6 +176,7 @@ type User {
roles: [String] roles: [String]
concernements: [Concernement] concernements: [Concernement]
groups: [Group] groups: [Group]
structure: [Taxoterm]
} }
# type Role { # type Role {

View File

@ -68,7 +68,7 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
// //
$this->addImage($registry, $builder); $this->addImage($registry, $builder);
// //
// $this->addTaxoterm($registry, $builder); $this->addTaxoterm($registry, $builder);
// //
$this->addLink($registry, $builder); $this->addLink($registry, $builder);
@ -202,11 +202,30 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
$registry->addFieldResolver('Concernement', 'author', $registry->addFieldResolver('Concernement', 'author',
$builder->compose( $builder->compose(
$builder->produce('entity_owner') $builder->produce('entity_owner')
->map('entity', $builder->fromParent()),
$builder->produce('entity_label')
->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
)); ));
$registry->addFieldResolver('Concernement', 'created',
$builder->compose(
$builder->produce('entity_created')
->map('entity', $builder->fromParent())
)
);
$registry->addFieldResolver('Concernement', 'changed',
$builder->compose(
$builder->produce('entity_changed')
->map('entity', $builder->fromParent())
)
);
$registry->addFieldResolver('Concernement', 'lieu',
$builder->produce('entity_reference')
->map('entity', $builder->fromParent())
->map('field', $builder->fromValue('field_lieu'))
);
// $registry->addFieldResolver('Concernement', 'recit', // $registry->addFieldResolver('Concernement', 'recit',
// $builder->produce('entity_reference') // $builder->produce('entity_reference')
// ->map('entity', $builder->fromParent()) // ->map('entity', $builder->fromParent())
@ -404,8 +423,8 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('entity', $builder->fromParent()), ->map('entity', $builder->fromParent()),
$builder->produce('entity_label') $builder->produce('entity_label')
->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
)); )
);
$registry->addFieldResolver('Entite', 'sources', $registry->addFieldResolver('Entite', 'sources',
$builder->produce('entity_reference_revisions') $builder->produce('entity_reference_revisions')
@ -413,7 +432,6 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('field', $builder->fromValue('field_sources')) ->map('field', $builder->fromValue('field_sources'))
); );
} }
// ____ // ____
@ -1308,6 +1326,12 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('ids', $builder->fromParent()) ->map('ids', $builder->fromParent())
) )
); );
$registry->addFieldResolver('User', 'structure',
$builder->produce('entity_reference')
->map('entity', $builder->fromParent())
->map('field', $builder->fromValue('field_strucure'))
);
} }
@ -1461,84 +1485,84 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
// | |/ _` / _` | // | |/ _` / _` |
// |_|\__,_\__, | // |_|\__,_\__, |
// |___/ // |___/
// protected function addTaxoterm(ResolverRegistryInterface $registry, ResolverBuilder $builder) { protected function addTaxoterm(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
// $registry->addFieldResolver('Query', 'alltags', // $registry->addFieldResolver('Query', 'alltags',
// $builder->compose( // $builder->compose(
// $builder->callback(function($parent, $arg){ // $builder->callback(function($parent, $arg){
// $entity_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); // $entity_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
// $query = $entity_storage->getQuery() // $query = $entity_storage->getQuery()
// ->condition('vid', ['tag','tag_prod'], 'IN') // ->condition('vid', ['tag','tag_prod'], 'IN')
// ->accessCheck(TRUE); // ->accessCheck(TRUE);
// $results = $query->execute(); // $results = $query->execute();
// return $results; // return $results;
// }), // }),
// $builder->produce('entity_load_multiple') // $builder->produce('entity_load_multiple')
// ->map('type', $builder->fromValue('taxonomy_term')) // ->map('type', $builder->fromValue('taxonomy_term'))
// ->map('ids', $builder->fromParent()) // ->map('ids', $builder->fromParent())
// ) // )
// ); // );
// $registry->addFieldResolver('Query', 'tag', // $registry->addFieldResolver('Query', 'tag',
// $builder->produce('entity_load') // $builder->produce('entity_load')
// ->map('type', $builder->fromValue('taxonomy_term')) // ->map('type', $builder->fromValue('taxonomy_term'))
// ->map('bundles', $builder->fromValue(['tag'])) // ->map('bundles', $builder->fromValue(['tag']))
// ->map('id', $builder->fromArgument('id')) // ->map('id', $builder->fromArgument('id'))
// ); // );
// $registry->addFieldResolver('Query', 'famille', // $registry->addFieldResolver('Query', 'famille',
// $builder->produce('entity_load') // $builder->produce('entity_load')
// ->map('type', $builder->fromValue('taxonomy_term')) // ->map('type', $builder->fromValue('taxonomy_term'))
// ->map('bundles', $builder->fromValue(['famille'])) // ->map('bundles', $builder->fromValue(['famille']))
// ->map('id', $builder->fromArgument('id')) // ->map('id', $builder->fromArgument('id'))
// ); // );
// $registry->addFieldResolver('Query', 'tagprod', // $registry->addFieldResolver('Query', 'tagprod',
// $builder->produce('entity_load') // $builder->produce('entity_load')
// ->map('type', $builder->fromValue('taxonomy_term')) // ->map('type', $builder->fromValue('taxonomy_term'))
// ->map('bundles', $builder->fromValue(['tag_prod'])) // ->map('bundles', $builder->fromValue(['tag_prod']))
// ->map('id', $builder->fromArgument('id')) // ->map('id', $builder->fromArgument('id'))
// ); // );
// // get all tags for a given familly // get all tags for a given familly
// // $registry->addFieldResolver('Query', 'famillytags', // $registry->addFieldResolver('Query', 'famillytags',
// // $builder->compose( // $builder->compose(
// // $builder->callback(function($parent, $arg){ // $builder->callback(function($parent, $arg){
// // $entity_storage = \Drupal::entityTypeManager()->getStorage('node'); // $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
// // $query = $entity_storage->getQuery() // $query = $entity_storage->getQuery()
// // ->condition('type', ['texte', 'texte_prod'], 'IN') // ->condition('type', ['texte', 'texte_prod'], 'IN')
// // ->condition('field_famille', $arg->famillyid) // ->condition('field_famille', $arg->famillyid)
// // ->accessCheck(TRUE); // ->accessCheck(TRUE);
// // $results = $query->execute(); // $results = $query->execute();
// // return $results; // return $results;
// // }), // }),
// // $builder->produce('entity_load_multiple') // $builder->produce('entity_load_multiple')
// // ->map('type', $builder->fromValue('node')) // ->map('type', $builder->fromValue('node'))
// // ->map('ids', $builder->fromParent()) // ->map('ids', $builder->fromParent())
// // // $builder->produce('entity_load_multiple') // // $builder->produce('entity_load_multiple')
// // // ->map('type', $builder->fromValue('taxonomy_term')) // // ->map('type', $builder->fromValue('taxonomy_term'))
// // // ->map('ids', $builder->fromParent()) // // ->map('ids', $builder->fromParent())
// // ) // )
// // ); // );
// $registry->addFieldResolver('Taxoterm', 'id', $registry->addFieldResolver('Taxoterm', 'id',
// $builder->produce('entity_id') $builder->produce('entity_id')
// ->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
// ); );
// $registry->addFieldResolver('Taxoterm', 'uuid', $registry->addFieldResolver('Taxoterm', 'uuid',
// $builder->produce('entity_uuid') $builder->produce('entity_uuid')
// ->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
// ); );
// $registry->addFieldResolver('Taxoterm', 'name', $registry->addFieldResolver('Taxoterm', 'name',
// $builder->produce('entity_label') $builder->produce('entity_label')
// ->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
// ); );
// $registry->addFieldResolver('Taxoterm', 'vocabulary', $registry->addFieldResolver('Taxoterm', 'vocabulary',
// $builder->produce('entity_bundle') $builder->produce('entity_bundle')
// ->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
// ); );
// } }
// _ _ _ // _ _ _