diff --git a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls index 9489e04..0dc0407 100644 --- a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls +++ b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls @@ -3,6 +3,8 @@ scalar Violation interface NodeInterface { id: Int! path: String! + created: String + changed: String } type Concernement implements NodeInterface { @@ -11,7 +13,10 @@ type Concernement implements NodeInterface { uuid: String! bundle: String! title: String! - author: String + author: User + created: String + changed: String + lieu: [Taxoterm] description: String caillou: String recit: Filefield @@ -34,6 +39,8 @@ type Entite implements NodeInterface { bundle: String! title: String! author: String + created: String + changed: String action: String menacemaintien: String superposition: [Entite] @@ -56,6 +63,8 @@ type Besoin implements NodeInterface { id: Int! path: String! author: String + created: String + changed: String description: String! index: Int concernement: Concernement @@ -66,6 +75,8 @@ type Reponse implements NodeInterface { id: Int! path: String! author: String + created: String + changed: String besoin: Besoin qui: String quoi: String @@ -80,6 +91,8 @@ type Doleance implements NodeInterface { bundle: String! title: String! author: String + created: String + changed: String #1 leprobleme: String lenquete: String @@ -135,6 +148,8 @@ type Static implements NodeInterface { title: String! path: String! author: String + created: String + changed: String texte: String } @@ -161,6 +176,7 @@ type User { roles: [String] concernements: [Concernement] groups: [Group] + structure: [Taxoterm] } # type Role { diff --git a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php index 0b6e976..e77d5b4 100644 --- a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php +++ b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php @@ -68,7 +68,7 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { // $this->addImage($registry, $builder); // - // $this->addTaxoterm($registry, $builder); + $this->addTaxoterm($registry, $builder); // $this->addLink($registry, $builder); @@ -202,11 +202,30 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { $registry->addFieldResolver('Concernement', 'author', $builder->compose( $builder->produce('entity_owner') - ->map('entity', $builder->fromParent()), - $builder->produce('entity_label') ->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', // $builder->produce('entity_reference') // ->map('entity', $builder->fromParent()) @@ -404,8 +423,8 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('entity', $builder->fromParent()), $builder->produce('entity_label') ->map('entity', $builder->fromParent()) - )); - + ) + ); $registry->addFieldResolver('Entite', 'sources', $builder->produce('entity_reference_revisions') @@ -413,7 +432,6 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('field', $builder->fromValue('field_sources')) ); - } // ____ @@ -1308,6 +1326,12 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->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) { - // $registry->addFieldResolver('Query', 'alltags', - // $builder->compose( - // $builder->callback(function($parent, $arg){ - // $entity_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); - // $query = $entity_storage->getQuery() - // ->condition('vid', ['tag','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()) - // ) - // ); + 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', ['tag','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')) - // ->map('bundles', $builder->fromValue(['tag'])) - // ->map('id', $builder->fromArgument('id')) - // ); - // $registry->addFieldResolver('Query', 'famille', - // $builder->produce('entity_load') - // ->map('type', $builder->fromValue('taxonomy_term')) - // ->map('bundles', $builder->fromValue(['famille'])) - // ->map('id', $builder->fromArgument('id')) - // ); - // $registry->addFieldResolver('Query', 'tagprod', - // $builder->produce('entity_load') - // ->map('type', $builder->fromValue('taxonomy_term')) - // ->map('bundles', $builder->fromValue(['tag_prod'])) - // ->map('id', $builder->fromArgument('id')) - // ); + // $registry->addFieldResolver('Query', 'tag', + // $builder->produce('entity_load') + // ->map('type', $builder->fromValue('taxonomy_term')) + // ->map('bundles', $builder->fromValue(['tag'])) + // ->map('id', $builder->fromArgument('id')) + // ); + // $registry->addFieldResolver('Query', 'famille', + // $builder->produce('entity_load') + // ->map('type', $builder->fromValue('taxonomy_term')) + // ->map('bundles', $builder->fromValue(['famille'])) + // ->map('id', $builder->fromArgument('id')) + // ); + // $registry->addFieldResolver('Query', 'tagprod', + // $builder->produce('entity_load') + // ->map('type', $builder->fromValue('taxonomy_term')) + // ->map('bundles', $builder->fromValue(['tag_prod'])) + // ->map('id', $builder->fromArgument('id')) + // ); - // // get all tags for a given familly - // // $registry->addFieldResolver('Query', 'famillytags', - // // $builder->compose( - // // $builder->callback(function($parent, $arg){ - // // $entity_storage = \Drupal::entityTypeManager()->getStorage('node'); - // // $query = $entity_storage->getQuery() - // // ->condition('type', ['texte', 'texte_prod'], 'IN') - // // ->condition('field_famille', $arg->famillyid) - // // ->accessCheck(TRUE); - // // $results = $query->execute(); - // // return $results; - // // }), - // // $builder->produce('entity_load_multiple') - // // ->map('type', $builder->fromValue('node')) - // // ->map('ids', $builder->fromParent()) - // // // $builder->produce('entity_load_multiple') - // // // ->map('type', $builder->fromValue('taxonomy_term')) - // // // ->map('ids', $builder->fromParent()) - // // ) - // // ); + // get all tags for a given familly + // $registry->addFieldResolver('Query', 'famillytags', + // $builder->compose( + // $builder->callback(function($parent, $arg){ + // $entity_storage = \Drupal::entityTypeManager()->getStorage('node'); + // $query = $entity_storage->getQuery() + // ->condition('type', ['texte', 'texte_prod'], 'IN') + // ->condition('field_famille', $arg->famillyid) + // ->accessCheck(TRUE); + // $results = $query->execute(); + // return $results; + // }), + // $builder->produce('entity_load_multiple') + // ->map('type', $builder->fromValue('node')) + // ->map('ids', $builder->fromParent()) + // // $builder->produce('entity_load_multiple') + // // ->map('type', $builder->fromValue('taxonomy_term')) + // // ->map('ids', $builder->fromParent()) + // ) + // ); - // $registry->addFieldResolver('Taxoterm', 'id', - // $builder->produce('entity_id') - // ->map('entity', $builder->fromParent()) - // ); + $registry->addFieldResolver('Taxoterm', 'id', + $builder->produce('entity_id') + ->map('entity', $builder->fromParent()) + ); - // $registry->addFieldResolver('Taxoterm', 'uuid', - // $builder->produce('entity_uuid') - // ->map('entity', $builder->fromParent()) - // ); + $registry->addFieldResolver('Taxoterm', 'uuid', + $builder->produce('entity_uuid') + ->map('entity', $builder->fromParent()) + ); - // $registry->addFieldResolver('Taxoterm', 'name', - // $builder->produce('entity_label') - // ->map('entity', $builder->fromParent()) - // ); + $registry->addFieldResolver('Taxoterm', 'name', + $builder->produce('entity_label') + ->map('entity', $builder->fromParent()) + ); - // $registry->addFieldResolver('Taxoterm', 'vocabulary', - // $builder->produce('entity_bundle') - // ->map('entity', $builder->fromParent()) - // ); - // } + $registry->addFieldResolver('Taxoterm', 'vocabulary', + $builder->produce('entity_bundle') + ->map('entity', $builder->fromParent()) + ); + } // _ _ _