From 248304b461be428efc5878132ee6ad2e598ab4bd Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 9 Jul 2021 16:06:16 +0200 Subject: [PATCH] update allmapitemsof with fake creation family id --- .../SchemaExtension/EnFrSchemaExtension.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 2229933..a721c4e 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 @@ -210,10 +210,18 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase { $builder->compose( $builder->callback(function($parent, $arg){ $entity_storage = \Drupal::entityTypeManager()->getStorage('node'); - $query = $entity_storage->getQuery() - ->condition('type', ['texte', 'texte_prod'], 'IN') - ->condition('field_famille', $arg) - ->accessCheck(TRUE); + $query = $entity_storage->getQuery(); + // creations have no family, return creation for id == 0 + if ($arg['familyId'] == 0) { + $query + ->condition('type', ['creation'], 'IN') + ->accessCheck(TRUE); + } else { + $query + ->condition('type', ['texte', 'texte_prod'], 'IN') + ->condition('field_famille', $arg) + ->accessCheck(TRUE); + } $results = $query->execute(); return $results; }),