Skip to content

Commit

Permalink
docs(schema): Add comment about the noLocation option (#1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
klausi authored Nov 11, 2023
1 parent 9e99862 commit 5d7ceca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Plugin/GraphQL/Schema/AlterableComposableSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
3 changes: 3 additions & 0 deletions src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down

0 comments on commit 5d7ceca

Please sign in to comment.