Browse Source

gql entite field_confidentialite

bach 1 month ago
parent
commit
387d6e7aac

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

@@ -59,7 +59,7 @@ type Entite implements NodeInterface {
   sources: [Source]
   concernement: Concernement
   image: [Image]
-  
+  confidentialite: String
 }
 
 type Source {

+ 17 - 1
src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php

@@ -568,7 +568,23 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
         })
       )
     );
-  
+
+    // $registry->addFieldResolver('Entite', 'confidentialite',
+    //   $builder->compose(
+    //     $builder->callback(function(/** @var Drupal\node\Entity\node */ $parent, $arg){
+    //       $user = \Drupal::currentUser();
+    //       $can_update = $parent->access('update', $user);
+    //       return 'hello';
+    //     })
+    //   )
+    // );
+    $registry->addFieldResolver('Entite', 'confidentialite',
+      $builder->produce('property_path')
+        ->map('type', $builder->fromValue('entity:node'))
+        ->map('value', $builder->fromParent())
+        ->map('path', $builder->fromValue('field_confidentialite.value'))
+      );
+
 
   }