drupal-graphql / graphql

GraphQL integration for Drupal 9/10
288 stars 202 forks source link

AlterableComposableSchema::getExtensionDocument returning NULL #1395

Closed almunnings closed 2 months ago

almunnings commented 4 months ago

Ahoy hoy

If you have a schema without any extensions, and you use the AlterSchemaExtensionDataEvent to add to $extensions, the $ast will always return NULL.

https://github.com/drupal-graphql/graphql/blob/8.x-4.x/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php#L172

$ast = !empty($extensions) ? Parser::parse(implode("\n\n", $event->getSchemaExtensionData()), ['noLocation' => TRUE]) : NULL;

Should probably read:

$extensions = $event->getSchemaExtensionData();
$ast = !empty($extensions) ? Parser::parse(implode("\n\n", $extensions), ['noLocation' => TRUE]) : NULL;

Ran into this with GraphQL Compose. The sdl extensions are injected via the event, not via schema extensions.

Please and thank you.