From c8af50451c64dbda59b6ff3ed55694d9fa22066b Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 18 May 2021 23:04:17 +0200 Subject: [PATCH] gql creation --- .../graphql/enfr_extension.base.graphqls | 3 +++ .../SchemaExtension/EnFrSchemaExtension.php | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/web/modules/custom/enfrancais_graphql/graphql/enfr_extension.base.graphqls b/src/web/modules/custom/enfrancais_graphql/graphql/enfr_extension.base.graphqls index 5f699a2..c593f16 100644 --- a/src/web/modules/custom/enfrancais_graphql/graphql/enfr_extension.base.graphqls +++ b/src/web/modules/custom/enfrancais_graphql/graphql/enfr_extension.base.graphqls @@ -75,6 +75,9 @@ type Creation implements NodeInterface { texte: String auteurs: [Auteur] oeuvre: Link + date: Date # field_date + rebonds: [Creation] # field_rebonds + texte_de_depart: [Textref] # field_texte_de_depart } interface NoteInterface { diff --git a/src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php b/src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php index a21cee2..21bd637 100644 --- a/src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php +++ b/src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php @@ -610,6 +610,26 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('path', $builder->fromValue('field_oeuvre')) ); + $registry->addFieldResolver('Creation', 'rebonds', + $builder->compose( + $builder->produce('entity_reference') + ->map('entity', $builder->fromParent()) + ->map('field', $builder->fromValue('field_rebonds')) + )); + + $registry->addFieldResolver('Creation', 'texte_de_depart', + $builder->compose( + $builder->produce('entity_reference') + ->map('entity', $builder->fromParent()) + ->map('field', $builder->fromValue('field_texte_de_depart')) + )); + + $registry->addFieldResolver('Creation', 'date', + $builder->produce('property_path') + ->map('type', $builder->fromValue('entity:node')) + ->map('value', $builder->fromParent()) + ->map('path', $builder->fromValue('field_date')) + ); } // ___ _