You are here

protected function SdlSchemaPluginBase::getSchemaDefinition in GraphQL 8.4

Retrieves the raw schema definition string.

Return value

string The schema definition.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to SdlSchemaPluginBase::getSchemaDefinition()
SdlSchemaPluginBase::getSchemaDocument in src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php
Retrieves the parsed AST of the schema definition.
1 method overrides SdlSchemaPluginBase::getSchemaDefinition()
ComposableSchema::getSchemaDefinition in src/Plugin/GraphQL/Schema/ComposableSchema.php
Retrieves the raw schema definition string.

File

src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php, line 224

Class

SdlSchemaPluginBase
Base class that can be used by schema plugins.

Namespace

Drupal\graphql\Plugin\GraphQL\Schema

Code

protected function getSchemaDefinition() {
  $id = $this
    ->getPluginId();
  $definition = $this
    ->getPluginDefinition();
  $module = $this->moduleHandler
    ->getModule($definition['provider']);
  $path = 'graphql/' . $id . '.graphqls';
  $file = $module
    ->getPath() . '/' . $path;
  if (!file_exists($file)) {
    throw new InvalidPluginDefinitionException($id, sprintf('The module "%s" needs to have a schema definition "%s" in its folder for "%s" to be valid.', $module
      ->getName(), $path, $definition['class']));
  }
  return file_get_contents($file) ?: NULL;
}