Browse Source

gql paragraph id

bach 1 month ago
parent
commit
4744496526

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

@@ -63,6 +63,7 @@ type Entite implements NodeInterface {
 }
 
 type Source {
+  id: Int!
   audios: [Filefield]
   date: Date
   documents: [Filefield]

+ 15 - 4
src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php

@@ -595,6 +595,10 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
   //  |____/ \___/ \__,_|_|  \___\___|                           
   protected function addSource(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
 
+    $registry->addFieldResolver('Source', 'id',
+      $builder->produce('entity_id')
+        ->map('entity', $builder->fromParent())
+      );
     
     $registry->addFieldResolver('Source', 'description',
       $builder->produce('property_path')
@@ -603,11 +607,18 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
         ->map('path', $builder->fromValue('field_description.value'))
       );
     
+    // $registry->addFieldResolver('Source', 'images',
+    //   $builder->produce('entity_reference')
+    //     ->map('entity', $builder->fromParent())
+    //     ->map('field', $builder->fromValue('field_images'))
+    //   );
+    // images: [Image]
     $registry->addFieldResolver('Source', 'images',
-      $builder->produce('entity_reference')
-        ->map('entity', $builder->fromParent())
-        ->map('field', $builder->fromValue('field_images'))
-      );
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:paragraph'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_images'))
+    );
 
     $registry->addFieldResolver('Source', 'videos',
       $builder->produce('property_path')