Browse Source

added revisions field to concernement graphql schema #2203

bach 1 year ago
parent
commit
ff6a9285db

+ 1 - 0
src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls

@@ -25,6 +25,7 @@ type Concernement implements NodeInterface {
   entites: [Entiteintegre]
   besoins: [Besoin]
   doleances: [Doleance]
+  revisions: [Concernement]
 }
 
 type Entiteintegre {

+ 10 - 3
src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php

@@ -297,9 +297,16 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
 
     // revisions: [Concernement]
     $registry->addFieldResolver('Concernement', 'revisions',
-      $builder->produce('entity_reference')
-        ->map('entity', $builder->fromParent())
-        ->map('field', $builder->fromValue('field_doleancer'))
+      $builder->compose(
+        $builder->callback(function($parent, $arg){
+          $vids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($parent);
+          $revisions = [];
+          foreach($vids as $vid){
+            $revisions[] = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($vid);
+          }
+          return $revisions;
+        })
+      )
     );
   
   }