class ComposableSchema in GraphQL 8.4
Plugin annotation
@Schema(
id = "composable",
name = "Composable schema"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase implements CacheableDependencyInterface, ContainerFactoryPluginInterface, SchemaPluginInterface uses RefinableCacheableDependencyTrait
- class \Drupal\graphql\Plugin\GraphQL\Schema\ComposableSchema implements ConfigurableInterface, PluginFormInterface uses StringTranslationTrait
- class \Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase implements CacheableDependencyInterface, ContainerFactoryPluginInterface, SchemaPluginInterface uses RefinableCacheableDependencyTrait
Expanded class hierarchy of ComposableSchema
1 file declares its use of ComposableSchema
- ComposableSchemaExample.php in examples/
graphql_composable/ src/ Plugin/ GraphQL/ Schema/ ComposableSchemaExample.php
File
- src/
Plugin/ GraphQL/ Schema/ ComposableSchema.php, line 18
Namespace
Drupal\graphql\Plugin\GraphQL\SchemaView source
class ComposableSchema extends SdlSchemaPluginBase implements ConfigurableInterface, PluginFormInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getResolverRegistry() {
return new ResolverRegistry();
}
/**
* {@inheritdoc}
*/
protected function getExtensions() {
return array_map(function ($id) {
return $this->extensionManager
->createInstance($id);
}, array_filter($this
->getConfiguration()['extensions']));
}
/**
* {@inheritdoc}
*/
protected function getSchemaDefinition() {
return <<<GQL
type Schema {
query: Query
}
type Query
GQL;
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) : void {
$this->configuration = NestedArray::mergeDeep($this
->defaultConfiguration(), $configuration);
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$extensions = $this->extensionManager
->getDefinitions();
$form['extensions'] = [
'#type' => 'checkboxes',
'#required' => FALSE,
'#title' => $this
->t('Enabled extensions'),
'#options' => [],
'#default_value' => $this->configuration['extensions'] ?? [],
];
foreach ($extensions as $key => $extension) {
$form['extensions']['#options'][$key] = $extension['name'] ?? $extension['id'];
if (!empty($extension['description'])) {
$form['extensions'][$key]['#description'] = $extension['description'];
}
}
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $formState) : void {
// @todo Validate dependencies between extensions.
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $formState) : void {
// Nothing to do here.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
ComposableSchema:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
ComposableSchema:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
|
ComposableSchema:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ComposableSchema:: |
protected | function |
Overrides SdlSchemaPluginBase:: |
|
ComposableSchema:: |
public | function |
Retrieves the resolver registry. Overrides SchemaPluginInterface:: |
|
ComposableSchema:: |
protected | function |
Retrieves the raw schema definition string. Overrides SdlSchemaPluginBase:: |
|
ComposableSchema:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
ComposableSchema:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
ComposableSchema:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
SdlSchemaPluginBase:: |
protected | property | The cache bin for caching the parsed SDL. | |
SdlSchemaPluginBase:: |
protected | property | The schema extension plugin manager. | |
SdlSchemaPluginBase:: |
protected | property | Whether the system is currently in development mode. | |
SdlSchemaPluginBase:: |
protected | property | The module handler service. | |
SdlSchemaPluginBase:: |
public static | function |
@codeCoverageIgnore Overrides ContainerFactoryPluginInterface:: |
|
SdlSchemaPluginBase:: |
protected | function | Retrieves the parsed AST of the schema extension definitions. | |
SdlSchemaPluginBase:: |
public | function |
Overrides SchemaPluginInterface:: |
|
SdlSchemaPluginBase:: |
protected | function | Retrieves the parsed AST of the schema definition. | |
SdlSchemaPluginBase:: |
public | function |
SdlSchemaPluginBase constructor. Overrides PluginBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |