From 12e0d6a07b0f98b66cd10317fed6632a731676bf Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 3 Jun 2024 14:09:13 +0200 Subject: [PATCH] gql besoins confidentialite field --- .../graphql/ouatt_extension.base.graphqls | 1 + .../SchemaExtension/OuattSchemaExtension.php | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) 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 e197180..979a0fb 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 @@ -90,6 +90,7 @@ type Besoin implements NodeInterface { index: Int concernement: Concernement reponses: [Reponse] + confidentialite: String } type Reponse implements NodeInterface { 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 aa6fe56..d3e727b 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 @@ -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')) + ); + } // ____