protected function SdlSchemaExtensionPluginBase::loadDefinitionFile in GraphQL 8.4
Loads a schema definition file.
Parameters
string $type: The type of the definition file to load.
Return value
string|null The loaded definition file content or NULL if it was empty.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
2 calls to SdlSchemaExtensionPluginBase::loadDefinitionFile()
- SdlSchemaExtensionPluginBase::getBaseDefinition in src/
Plugin/ GraphQL/ SchemaExtension/ SdlSchemaExtensionPluginBase.php - SdlSchemaExtensionPluginBase::getExtensionDefinition in src/
Plugin/ GraphQL/ SchemaExtension/ SdlSchemaExtensionPluginBase.php
File
- src/
Plugin/ GraphQL/ SchemaExtension/ SdlSchemaExtensionPluginBase.php, line 91
Class
- SdlSchemaExtensionPluginBase
- Base class that can be used for schema extension plugins.
Namespace
Drupal\graphql\Plugin\GraphQL\SchemaExtensionCode
protected function loadDefinitionFile($type) {
$id = $this
->getPluginId();
$definition = $this
->getPluginDefinition();
$module = $this->moduleHandler
->getModule($definition['provider']);
$path = 'graphql/' . $id . '.' . $type . '.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;
}