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 50d88c0..5f699a2 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 @@ -37,6 +37,7 @@ type Textref implements NodeInterface & TextInterface{ field_titre_regular: String field_titre_italique: String edition: [Taxoterm] + lien_reference: Link text_produits: [Textprod] text_en_rebond: [Textref] tags: [Taxoterm] 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 9abfcb1..a21cee2 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 @@ -77,7 +77,7 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { // // $this->addAddress($registry, $builder); // - // $this->addLink($registry, $builder); + $this->addLink($registry, $builder); // // $this->addShowroom($registry, $builder); // @@ -317,6 +317,13 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('field', $builder->fromValue('field_edition')) ); + $registry->addFieldResolver('Textref', 'lien_reference', + $builder->produce('property_path') + ->map('type', $builder->fromValue('entity:node')) + ->map('value', $builder->fromParent()) + ->map('path', $builder->fromValue('field_lien_reference')) + ); + $registry->addFieldResolver('Textref', 'fichiers', $builder->produce('entity_reference') ->map('entity', $builder->fromParent()) @@ -542,6 +549,8 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('id', $builder->fromArgument('id')) ); + + $registry->addFieldResolver('Creation', 'id', $builder->produce('entity_id') ->map('entity', $builder->fromParent()) @@ -573,7 +582,7 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('entity', $builder->fromParent()) )); - $registry->addFieldResolver('Creation', 'description', + $registry->addFieldResolver('Creation', 'texte', $builder->produce('property_path') ->map('type', $builder->fromValue('entity:node')) ->map('value', $builder->fromParent()) @@ -857,6 +866,8 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('id', $builder->fromArgument('id')) ); + + $registry->addFieldResolver('Taxoterm', 'id', $builder->produce('entity_id') ->map('entity', $builder->fromParent()) @@ -933,4 +944,20 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { } + // _ _ _ + // | | (_)_ _ | |__ + // | |__| | ' \| / / + // |____|_|_||_|_\_\ + protected function addLink(ResolverRegistryInterface $registry, ResolverBuilder $builder) { + $registry->addFieldResolver('Link', 'url', + $builder->callback(function ($parent, $args) { + return isset($parent[0]) ? $parent[0]['uri'] : null; + }) + ); + $registry->addFieldResolver('Link', 'title', + $builder->callback(function ($parent, $args) { + return isset($parent[0]) ? $parent[0]['title'] : null; + }) + ); + } }