浏览代码

gql besoins confidentialite field

bach 5 月之前
父节点
当前提交
12e0d6a07b

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

@@ -90,6 +90,7 @@ type Besoin implements NodeInterface {
   index: Int
   concernement: Concernement
   reponses: [Reponse]
+  confidentialite: String
 }
 
 type Reponse implements NodeInterface {

+ 16 - 8
src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php

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