1 | <?php |
||
15 | abstract class CreateEntityBase extends MutationPluginBase implements ContainerFactoryPluginInterface { |
||
16 | use DependencySerializationTrait; |
||
17 | use StringTranslationTrait; |
||
18 | |||
19 | /** |
||
20 | * The entity type manager. |
||
21 | * |
||
22 | * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
||
23 | */ |
||
24 | protected $entityTypeManager; |
||
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function __construct(array $configuration, $pluginId, $pluginDefinition, EntityTypeManagerInterface $entityTypeManager) { |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) { |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function resolve($value, array $args, ResolveInfo $info) { |
||
86 | |||
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 | |||
102 | } |
||
103 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: