66use Drupal \Core \Entity \EntityTypeManagerInterface ;
77use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
88use Drupal \Core \StringTranslation \StringTranslationTrait ;
9+ use Drupal \graphql \Plugin \GraphQL \InputTypes \InputTypePluginBase ;
910use Drupal \graphql_core \GraphQL \EntityCrudOutputWrapper ;
1011use Drupal \graphql \Plugin \GraphQL \Mutations \MutationPluginBase ;
11- use Drupal \graphql_core \Plugin \GraphQL \Mutations \Entity \EntityMutationInputTrait ;
1212use Symfony \Component \DependencyInjection \ContainerInterface ;
1313use 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}
0 commit comments