diff --git a/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php b/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php index 31dda11f2..0f50a9f12 100644 --- a/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php +++ b/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php @@ -130,6 +130,9 @@ protected function getSchemaDocument(array $extensions = []) { $event, AlterSchemaDataEvent::EVENT_NAME ); + // For caching and parsing big schemas we need to disable the creation of + // location nodes in the AST object to prevent serialization and memory + // errors. See https://github.com/webonyx/graphql-php/issues/1164 $ast = Parser::parse(implode("\n\n", $event->getSchemaData()), ['noLocation' => TRUE]); if (empty($this->inDevelopment)) { $this->astCache->set($cid, $ast, CacheBackendInterface::CACHE_PERMANENT, ['graphql']); diff --git a/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php b/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php index ffd25b128..cae50d5d0 100644 --- a/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php +++ b/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php @@ -174,6 +174,9 @@ protected function getSchemaDocument(array $extensions = []) { }); $schema = array_merge([$this->getSchemaDefinition()], $extensions); + // For caching and parsing big schemas we need to disable the creation of + // location nodes in the AST object to prevent serialization and memory + // errors. See https://github.com/webonyx/graphql-php/issues/1164 $ast = Parser::parse(implode("\n\n", $schema), ['noLocation' => TRUE]); if (empty($this->inDevelopment)) { $this->astCache->set($cid, $ast, CacheBackendInterface::CACHE_PERMANENT, ['graphql']);