abstract class UnionTypePluginBase in GraphQL 8.3
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\graphql\Plugin\GraphQL\Unions\UnionTypePluginBase implements TypePluginInterface uses DescribablePluginTrait
Expanded class hierarchy of UnionTypePluginBase
1 file declares its use of UnionTypePluginBase
- MockGraphQLPluginTrait.php in tests/
src/ Traits/ MockGraphQLPluginTrait.php
1 string reference to 'UnionTypePluginBase'
File
- src/
Plugin/ GraphQL/ Unions/ UnionTypePluginBase.php, line 13
Namespace
Drupal\graphql\Plugin\GraphQL\UnionsView source
abstract class UnionTypePluginBase extends PluginBase implements TypePluginInterface {
use DescribablePluginTrait;
/**
* {@inheritdoc}
*/
public static function createInstance(SchemaBuilderInterface $builder, TypePluginManager $manager, $definition, $id) {
return new UnionType([
'name' => $definition['name'],
'description' => $definition['description'],
'types' => function () use ($builder, $definition) {
return array_map(function ($type) use ($builder) {
if (!($type = $builder
->getType($type)) instanceof ObjectType) {
throw new \LogicException('Union types can only reference object types.');
}
return $type;
}, $builder
->getSubTypes($definition['name']));
},
'resolveType' => function ($value, $context, $info) use ($builder, $definition) {
return $builder
->resolveType($definition['name'], $value, $context, $info);
},
]);
}
/**
* {@inheritdoc}
*/
public function getDefinition() {
$definition = $this
->getPluginDefinition();
return [
'name' => $definition['name'],
'description' => $this
->buildDescription($definition),
'types' => $this
->buildTypes($definition),
];
}
/**
* Builds the list of types contained within this union type.
*
* @param array $definition
* The plugin definion array.
*
* @return array
* The list of types contained within this union type.
*/
protected function buildTypes($definition) {
return $definition['types'] ?: [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DescribablePluginTrait:: |
protected | function | ||
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. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
UnionTypePluginBase:: |
protected | function | Builds the list of types contained within this union type. | |
UnionTypePluginBase:: |
public static | function |
Overrides TypePluginInterface:: |
|
UnionTypePluginBase:: |
public | function |
Returns the plugin's type or field definition for the schema. Overrides TypePluginInterface:: |