Skip to content

Commit 9f5f1b3

Browse files
authored
Remove generated mutations. (#409)
1 parent 58ea895 commit 9f5f1b3

21 files changed

Lines changed: 133 additions & 80 deletions

modules/graphql_core/src/Plugin/GraphQL/Mutations/Entity/CreateEntity.php renamed to modules/graphql_core/src/Plugin/GraphQL/Mutations/Entity/CreateEntityBase.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,15 @@
66
use Drupal\Core\Entity\EntityTypeManagerInterface;
77
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
88
use Drupal\Core\StringTranslation\StringTranslationTrait;
9-
use Drupal\graphql_core\Plugin\GraphQL\Mutations\Entity\EntityMutationInputTrait;
9+
use Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase;
1010
use Drupal\graphql_core\GraphQL\EntityCrudOutputWrapper;
1111
use Drupal\graphql\Plugin\GraphQL\Mutations\MutationPluginBase;
1212
use Symfony\Component\DependencyInjection\ContainerInterface;
1313
use Youshido\GraphQL\Execution\ResolveInfo;
1414

15-
/**
16-
* Create an entity.
17-
*
18-
* @GraphQLMutation(
19-
* id = "create_entity",
20-
* type = "EntityCrudOutput",
21-
* secure = true,
22-
* nullable = false,
23-
* schema_cache_tags = {"entity_types", "entity_bundles"},
24-
* deriver = "Drupal\graphql_core\Plugin\Deriver\Mutations\CreateEntityDeriver"
25-
* )
26-
*/
27-
class CreateEntity extends MutationPluginBase implements ContainerFactoryPluginInterface {
15+
abstract class CreateEntityBase extends MutationPluginBase implements ContainerFactoryPluginInterface {
2816
use DependencySerializationTrait;
2917
use StringTranslationTrait;
30-
use EntityMutationInputTrait;
3118

3219
/**
3320
* The entity type manager.
@@ -71,7 +58,7 @@ public function resolve($value, array $args, ResolveInfo $info) {
7158
$inputArgs = $args['input'];
7259
/** @var \Youshido\GraphQL\Type\Object\AbstractObjectType $type */
7360
$type = $this->config->getArgument('input')->getType();
74-
/** @var \Drupal\graphql_core\Plugin\GraphQL\InputTypes\Mutations\EntityInput $inputType */
61+
/** @var \Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase $inputType */
7562
$inputType = $type->getNamedType();
7663
$input = $this->extractEntityInput($inputArgs, $inputType);
7764

@@ -97,4 +84,19 @@ public function resolve($value, array $args, ResolveInfo $info) {
9784
return NULL;
9885
}
9986

87+
/**
88+
* Extract entity values from the resolver args.
89+
*
90+
* Loops over all input values and assigns them to their original field names.
91+
*
92+
* @param array $inputArgs
93+
* The entity values provided through the resolver args.
94+
* @param \Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase $inputType
95+
* The input type.
96+
*
97+
* @return array
98+
* The extracted entity values with their proper, internal field names.
99+
*/
100+
abstract protected function extractEntityInput(array $inputArgs, InputTypePluginBase $inputType);
101+
100102
}

modules/graphql_core/src/Plugin/GraphQL/Mutations/Entity/DeleteEntity.php renamed to modules/graphql_core/src/Plugin/GraphQL/Mutations/Entity/DeleteEntityBase.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,7 @@
1212
use Symfony\Component\DependencyInjection\ContainerInterface;
1313
use Youshido\GraphQL\Execution\ResolveInfo;
1414

15-
/**
16-
* Delete an entity.
17-
*
18-
* @GraphQLMutation(
19-
* id = "delete_entity",
20-
* type = "EntityCrudOutput",
21-
* secure = true,
22-
* arguments = {
23-
* "id" = "String"
24-
* },
25-
* nullable = false,
26-
* schema_cache_tags = {"entity_types"},
27-
* deriver = "Drupal\graphql_core\Plugin\Deriver\Mutations\DeleteEntityDeriver"
28-
* )
29-
*/
30-
class DeleteEntity extends MutationPluginBase implements ContainerFactoryPluginInterface {
15+
abstract class DeleteEntityBase extends MutationPluginBase implements ContainerFactoryPluginInterface {
3116
use DependencySerializationTrait;
3217
use StringTranslationTrait;
3318

modules/graphql_core/src/Plugin/GraphQL/Mutations/Entity/UpdateEntity.php renamed to modules/graphql_core/src/Plugin/GraphQL/Mutations/Entity/UpdateEntityBase.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,15 @@
66
use Drupal\Core\Entity\EntityTypeManagerInterface;
77
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
88
use Drupal\Core\StringTranslation\StringTranslationTrait;
9+
use Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase;
910
use Drupal\graphql_core\GraphQL\EntityCrudOutputWrapper;
1011
use Drupal\graphql\Plugin\GraphQL\Mutations\MutationPluginBase;
11-
use Drupal\graphql_core\Plugin\GraphQL\Mutations\Entity\EntityMutationInputTrait;
1212
use Symfony\Component\DependencyInjection\ContainerInterface;
1313
use Youshido\GraphQL\Execution\ResolveInfo;
1414

15-
/**
16-
* Update an entity.
17-
*
18-
* TODO: Add revision support.
19-
*
20-
* @GraphQLMutation(
21-
* id = "update_entity",
22-
* type = "EntityCrudOutput",
23-
* secure = true,
24-
* nullable = false,
25-
* schema_cache_tags = {"entity_types", "entity_bundles"},
26-
* deriver = "Drupal\graphql_core\Plugin\Deriver\Mutations\UpdateEntityDeriver"
27-
* )
28-
*/
29-
class UpdateEntity extends MutationPluginBase implements ContainerFactoryPluginInterface {
15+
abstract class UpdateEntityBase extends MutationPluginBase implements ContainerFactoryPluginInterface {
3016
use DependencySerializationTrait;
3117
use StringTranslationTrait;
32-
use EntityMutationInputTrait;
3318

3419
/**
3520
* The entity type manager.
@@ -91,7 +76,7 @@ public function resolve($value, array $args, ResolveInfo $info) {
9176
$inputArgs = $args['input'];
9277
/** @var \Youshido\GraphQL\Type\Object\AbstractObjectType $type */
9378
$type = $this->config->getArgument('input')->getType();
94-
/** @var \Drupal\graphql_core\Plugin\GraphQL\InputTypes\Mutations\EntityInput $inputType */
79+
/** @var \Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase $inputType */
9580
$inputType = $type->getNamedType();
9681
$input = $this->extractEntityInput($inputArgs, $inputType);
9782

@@ -117,5 +102,19 @@ public function resolve($value, array $args, ResolveInfo $info) {
117102
return NULL;
118103
}
119104

105+
/**
106+
* Extract entity values from the resolver args.
107+
*
108+
* Loops over all input values and assigns them to their original field names.
109+
*
110+
* @param array $inputArgs
111+
* The entity values provided through the resolver args.
112+
* @param \Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase $inputType
113+
* The input type.
114+
*
115+
* @return array
116+
* The extracted entity values with their proper, internal field names.
117+
*/
118+
abstract protected function extractEntityInput(array $inputArgs, InputTypePluginBase $inputType);
120119

121120
}

modules/graphql_core/src/Plugin/GraphQL/Schemas/DefaultSchema.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public static function create(ContainerInterface $container, array $configuratio
3030
$schemaBuilder = $schemaBuilderFactory->getSchemaBuilder();
3131

3232
$mutation = new InternalSchemaMutationObject(['name' => 'RootMutation']);
33-
$mutation->addFields($schemaBuilder->getMutations());
3433

3534
$query = new InternalSchemaQueryObject(['name' => 'RootQuery']);
3635
$query->addFields($schemaBuilder->getRootFields());

modules/graphql_core/src/Plugin/Deriver/InputTypes/EntityInputDeriver.php renamed to modules/graphql_legacy/graphql_mutation/src/Plugin/Deriver/InputTypes/EntityInputDeriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_core\Plugin\Deriver\InputTypes;
3+
namespace Drupal\graphql_mutation\Plugin\Deriver\InputTypes;
44

55
use Drupal\Component\Plugin\Derivative\DeriverBase;
66
use Drupal\Core\Entity\ContentEntityTypeInterface;

modules/graphql_core/src/Plugin/Deriver/InputTypes/EntityInputFieldDeriver.php renamed to modules/graphql_legacy/graphql_mutation/src/Plugin/Deriver/InputTypes/EntityInputFieldDeriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_core\Plugin\Deriver\InputTypes;
3+
namespace Drupal\graphql_mutation\Plugin\Deriver\InputTypes;
44

55
use Drupal\Component\Plugin\Derivative\DeriverBase;
66
use Drupal\Core\Entity\ContentEntityTypeInterface;

modules/graphql_core/src/Plugin/Deriver/Mutations/CreateEntityDeriver.php renamed to modules/graphql_legacy/graphql_mutation/src/Plugin/Deriver/Mutations/CreateEntityDeriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_core\Plugin\Deriver\Mutations;
3+
namespace Drupal\graphql_mutation\Plugin\Deriver\Mutations;
44

55
use Drupal\Component\Plugin\Derivative\DeriverBase;
66
use Drupal\Core\Entity\ContentEntityTypeInterface;

modules/graphql_core/src/Plugin/Deriver/Mutations/DeleteEntityDeriver.php renamed to modules/graphql_legacy/graphql_mutation/src/Plugin/Deriver/Mutations/DeleteEntityDeriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_core\Plugin\Deriver\Mutations;
3+
namespace Drupal\graphql_mutation\Plugin\Deriver\Mutations;
44

55
use Drupal\Component\Plugin\Derivative\DeriverBase;
66
use Drupal\Core\Entity\ContentEntityTypeInterface;

modules/graphql_core/src/Plugin/Deriver/Mutations/UpdateEntityDeriver.php renamed to modules/graphql_legacy/graphql_mutation/src/Plugin/Deriver/Mutations/UpdateEntityDeriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_core\Plugin\Deriver\Mutations;
3+
namespace Drupal\graphql_mutation\Plugin\Deriver\Mutations;
44

55
use Drupal\Component\Plugin\Derivative\DeriverBase;
66
use Drupal\Core\Entity\ContentEntityTypeInterface;

modules/graphql_core/src/Plugin/GraphQL/InputTypes/Mutations/EntityInput.php renamed to modules/graphql_legacy/graphql_mutation/src/Plugin/GraphQL/InputTypes/EntityInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_core\Plugin\GraphQL\InputTypes\Mutations;
3+
namespace Drupal\graphql_mutation\Plugin\GraphQL\InputTypes;
44

55
use Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase;
66

@@ -9,7 +9,7 @@
99
*
1010
* @GraphQLInputType(
1111
* id = "entity_input",
12-
* deriver = "Drupal\graphql_core\Plugin\Deriver\InputTypes\EntityInputDeriver"
12+
* deriver = "Drupal\graphql_mutation\Plugin\Deriver\InputTypes\EntityInputDeriver"
1313
* )
1414
*/
1515
class EntityInput extends InputTypePluginBase {

0 commit comments

Comments
 (0)