- Issue created by @Lukas von Blarer
- Merge request !37This is a temporary hack to fix the graphql requests → (Merged) created by Lukas von Blarer
- Status changed to Needs review
6 months ago 2:20pm 12 July 2024 - 🇨🇭Switzerland Lukas von Blarer
I needed a quick fix and simpy made all mentioned parameters required. This fixes the requests for me. But this probably should be fixed differently.
- Status changed to Needs work
6 months ago 3:45pm 12 July 2024 - 🇨🇭Switzerland Lukas von Blarer
I'm sorry, The cause of my errors was something else. Still, this should be fixed I guess.
- 🇧🇬Bulgaria pfrenssen Sofia
This should probably be fixed in the GraphQL module. They are now only calling the
::resolve()
method with a simplecall_user_func_array()
with the `$field` argument as the last one in the list. Ref.\Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase::resolveField()
This can be refactored to use the `ReflectionMethod` class to inspect the argument order. I asked an LLM for a suggested approach and got this example:
public function resolveField(FieldContext $field) { if (!method_exists($this, 'resolve')) { throw new \LogicException('Missing data producer resolve method.'); } $reflectionMethod = new \ReflectionMethod($this, 'resolve'); $params = $reflectionMethod->getParameters(); $arguments = []; $contextValues = $this->configuration['dataproducer_populate_default_values'] ?? TRUE ? $this->getContextValuesWithDefaults() : $this->getContextValues(); foreach ($params as $param) { $name = $param->getName(); if ($name === 'field') { $arguments[] = $field; } elseif (array_key_exists($name, $contextValues)) { $arguments[] = $contextValues[$name]; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); } else { throw new \InvalidArgumentException("Missing required argument: $name"); } } return $reflectionMethod->invokeArgs($this, $arguments); }
If this is fixed in the GraphQL module we can reorder the arguments into their proper positions and don't need to use an incorrect method signature.
-
pfrenssen →
committed 28a33e4c on 2.x authored by
Lukas von Blarer →
Issue #3461045 by Lukas von Blarer, pfrenssen: Optional parameter $...
-
pfrenssen →
committed 28a33e4c on 2.x authored by
Lukas von Blarer →
- Status changed to Fixed
4 months ago 3:41pm 5 September 2024 Automatically closed - issue fixed for 2 weeks with no activity.