-
Notifications
You must be signed in to change notification settings - Fork 202
Description
@pmelab @klausi I guess this is out of scope, but there seems to be an issue with the data producer argument default values.
For example, the entity_reference
plugin definition sets a default value for access
argument:
graphql/src/Plugin/GraphQL/DataProducer/Field/EntityReference.php
Lines 46 to 50 in 6961eac
* "access" = @ContextDefinition("boolean", | |
* label = @Translation("Check access"), | |
* required = FALSE, | |
* default_value = TRUE | |
* ), |
So I would guess that the resolve
method never gets null
for $access
argument. Right?
However, it is typehinted as ?bool
:
public function resolve(EntityInterface $entity, $field, ?string $language, ?array $bundles, ?bool $access, ?AccountInterface $accessUser, ?string $accessOperation, FieldContext $context) { |
Then, when we call DataProducerExecutionTrait::executeDataProducer()
without providing access
argument, the data producer receives access
as null
. So it does not check the access, even if this should be the default behavior.
I would suggest:
- Remove
?
from data producer arguments having default values. - Improve
DataProducerExecutionTrait::executeDataProducer()
to fill in default argument values.
Originally posted by @Leksat in #1232 (comment)