From ff6a9285db855c66931d5ffe3b3a8dc41b46cf91 Mon Sep 17 00:00:00 2001 From: bach Date: Fri, 14 Jul 2023 12:01:18 +0200 Subject: [PATCH] added revisions field to concernement graphql schema #2203 --- .../graphql/ouatt_extension.base.graphqls | 1 + .../SchemaExtension/OuattSchemaExtension.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 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 1d2723a..abd7522 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 @@ -25,6 +25,7 @@ type Concernement implements NodeInterface { entites: [Entiteintegre] besoins: [Besoin] doleances: [Doleance] + revisions: [Concernement] } type Entiteintegre { 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 a2f51a3..c107cfd 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 @@ -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; + }) + ) ); }