1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\graphql\Plugin\GraphQL\Mutations; |
4
|
|
|
|
5
|
|
|
use Drupal\Component\Plugin\PluginBase; |
6
|
|
|
use Drupal\graphql\GraphQL\Field\Field; |
7
|
|
|
use Drupal\graphql\Plugin\GraphQL\PluggableSchemaBuilderInterface; |
8
|
|
|
use Drupal\graphql\Plugin\GraphQL\Traits\ArgumentAwarePluginTrait; |
9
|
|
|
use Drupal\graphql\Plugin\GraphQL\Traits\CacheablePluginTrait; |
10
|
|
|
use Drupal\graphql\Plugin\GraphQL\Traits\NamedPluginTrait; |
11
|
|
|
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Base class for graphql mutation plugins. |
15
|
|
|
*/ |
16
|
|
|
abstract class MutationPluginBase extends PluginBase implements TypeSystemPluginInterface { |
17
|
|
|
use CacheablePluginTrait; |
18
|
|
|
use NamedPluginTrait; |
19
|
|
|
use ArgumentAwarePluginTrait; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The field instance. |
23
|
|
|
* |
24
|
|
|
* @var \Drupal\graphql\GraphQL\Field\Field |
25
|
|
|
*/ |
26
|
|
|
protected $definition; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
public function getDefinition(PluggableSchemaBuilderInterface $schemaBuilder) { |
32
|
|
|
if (!isset($this->definition)) { |
33
|
|
|
$definition = $this->getPluginDefinition(); |
34
|
|
|
|
35
|
|
|
$this->definition = new Field($this, TRUE, [ |
36
|
|
|
'name' => $this->buildName(), |
37
|
|
|
'description' => $this->buildDescription(), |
38
|
|
|
'type' => $this->buildType($schemaBuilder), |
39
|
|
|
'args' => $this->buildArguments($schemaBuilder), |
40
|
|
|
'isDeprecated' => !empty($definition['deprecated']), |
41
|
|
|
'deprecationReason' => !empty($definition['deprecated']) ? !empty($definition['deprecated']) : '', |
42
|
|
|
]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return $this->definition; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
|