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