From 0f75b4dbf43baf67973d715b825ddf6285ad14c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Espinoza Date: Thu, 24 Mar 2022 14:30:54 -0600 Subject: [PATCH 1/2] 1268: Now caching the schema string instead of the DocumentNode object because when the schema reach out certain size it couse unserialization issues breaking the schema caching --- src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php b/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php index 47d1e7f2c..ef777d20d 100644 --- a/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php +++ b/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php @@ -174,9 +174,12 @@ protected function getSchemaDocument(array $extensions = []) { }); $schema = array_merge([$this->getSchemaDefinition()], $extensions); - $ast = Parser::parse(implode("\n\n", $schema)); - if (empty($this->inDevelopment)) { - $this->astCache->set($cid, $ast, CacheBackendInterface::CACHE_PERMANENT, ['graphql']); + $schema = implode("\n\n", $schema); + // Parsing only to check syntax errors in the current schema. + $ast = Parser::parse($schema); + if (empty($this->inDevelopment) && $ast) { + // Caching schema string. + $this->astCache->set($cid, $schema, CacheBackendInterface::CACHE_PERMANENT, ['graphql']); } return $ast; From 148697d88062124cd455a72a85a99409f1dc708d Mon Sep 17 00:00:00 2001 From: Rodrigo Espinoza Date: Thu, 24 Mar 2022 14:46:23 -0600 Subject: [PATCH 2/2] 1268: removing not required condition --- src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php b/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php index ef777d20d..905579916 100644 --- a/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php +++ b/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php @@ -177,7 +177,7 @@ protected function getSchemaDocument(array $extensions = []) { $schema = implode("\n\n", $schema); // Parsing only to check syntax errors in the current schema. $ast = Parser::parse($schema); - if (empty($this->inDevelopment) && $ast) { + if (empty($this->inDevelopment)) { // Caching schema string. $this->astCache->set($cid, $schema, CacheBackendInterface::CACHE_PERMANENT, ['graphql']); }