@@ 14-49 (lines=36) @@ | ||
11 | use Drupal\graphql\Plugin\GraphQL\Traits\TypedPluginTrait; |
|
12 | use Drupal\graphql\Plugin\SchemaBuilderInterface; |
|
13 | ||
14 | abstract class SubscriptionPluginBase extends PluginBase implements SubscriptionPluginInterface { |
|
15 | use TypedPluginTrait; |
|
16 | use DescribablePluginTrait; |
|
17 | use ArgumentAwarePluginTrait; |
|
18 | use DeprecatablePluginTrait; |
|
19 | ||
20 | /** |
|
21 | * {@inheritdoc} |
|
22 | */ |
|
23 | public static function createInstance(SchemaBuilderInterface $builder, SubscriptionPluginManager $manager, $definition, $id) { |
|
24 | return [ |
|
25 | 'description' => $definition['description'], |
|
26 | 'deprecationReason' => $definition['deprecationReason'], |
|
27 | 'type' => $builder->processType($definition['type']), |
|
28 | 'args' => $builder->processArguments($definition['args']), |
|
29 | 'resolve' => function ($value, $args, $context, $info) use ($manager, $id) { |
|
30 | $instance = $manager->getInstance(['id' => $id]); |
|
31 | return call_user_func_array([$instance, 'resolve'], [$value, $args, $context, $info]); |
|
32 | }, |
|
33 | ]; |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * {@inheritdoc} |
|
38 | */ |
|
39 | public function getDefinition() { |
|
40 | $definition = $this->getPluginDefinition(); |
|
41 | ||
42 | return [ |
|
43 | 'type' => $this->buildType($definition), |
|
44 | 'description' => $this->buildDescription($definition), |
|
45 | 'args' => $this->buildArguments($definition), |
|
46 | 'deprecationReason' => $this->buildDeprecationReason($definition), |
|
47 | ]; |
|
48 | } |
|
49 | } |
|
50 |
@@ 14-49 (lines=36) @@ | ||
11 | use Drupal\graphql\Plugin\GraphQL\Traits\TypedPluginTrait; |
|
12 | use Drupal\graphql\Plugin\SchemaBuilderInterface; |
|
13 | ||
14 | abstract class MutationPluginBase extends PluginBase implements MutationPluginInterface { |
|
15 | use TypedPluginTrait; |
|
16 | use DescribablePluginTrait; |
|
17 | use ArgumentAwarePluginTrait; |
|
18 | use DeprecatablePluginTrait; |
|
19 | ||
20 | /** |
|
21 | * {@inheritdoc} |
|
22 | */ |
|
23 | public static function createInstance(SchemaBuilderInterface $builder, MutationPluginManager $manager, $definition, $id) { |
|
24 | return [ |
|
25 | 'description' => $definition['description'], |
|
26 | 'deprecationReason' => $definition['deprecationReason'], |
|
27 | 'type' => $builder->processType($definition['type']), |
|
28 | 'args' => $builder->processArguments($definition['args']), |
|
29 | 'resolve' => function ($value, $args, $context, $info) use ($manager, $id) { |
|
30 | $instance = $manager->getInstance(['id' => $id]); |
|
31 | return call_user_func_array([$instance, 'resolve'], [$value, $args, $context, $info]); |
|
32 | }, |
|
33 | ]; |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * {@inheritdoc} |
|
38 | */ |
|
39 | public function getDefinition() { |
|
40 | $definition = $this->getPluginDefinition(); |
|
41 | ||
42 | return [ |
|
43 | 'type' => $this->buildType($definition), |
|
44 | 'description' => $this->buildDescription($definition), |
|
45 | 'args' => $this->buildArguments($definition), |
|
46 | 'deprecationReason' => $this->buildDeprecationReason($definition), |
|
47 | ]; |
|
48 | } |
|
49 | } |
|
50 |