Explorar o código

added gql query text: Textinterface

bach %!s(int64=3) %!d(string=hai) anos
pai
achega
c05abd7ce5

+ 4 - 0
src/web/modules/custom/enfrancais_graphql/graphql/enfr_extension.extension.graphqls

@@ -6,6 +6,10 @@ extend type Query {
   texts: [TextInterface]
 }
 
+extend type Query {
+  text(id: Int!): TextInterface
+}
+
 extend type Query {
   textsdepart: [Textref]
 }

+ 6 - 0
src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php

@@ -142,6 +142,12 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
           ->map('ids', $builder->fromParent())
         )
     );
+
+    $registry->addFieldResolver('Query', 'text',
+      $builder->produce('entity_load')
+        ->map('type', $builder->fromValue('node'))
+        ->map('ids', $builder->fromParent())
+    );
   }
 
   //  _____        _        ___                     _