Having an PHP attribute GQL Input and Provider e.g.
#[GQL\Mutation(name: 'entitiesUpdate', type: Type::BOOLEAN)]
#[GQL\Arg(name: 'entities', type: '[EntityUpdateInput]!')]
public function consumersUpdate(array $entities): bool
{
foreach ($entities as $entity) {
...
}
return true;
}
#[GQL\Input]
class EntityUpdateInput
{
#[GQL\InputField(type: Type::STRING)]
#[Assert\Email]
public ?string $email;
...
}
and then having a mutation run like so:
mutation {
entitiesUpdate(
entities: [
{
...
email: "invalid1"
}
{
...
email: "invalid2"
}
]
)
}
I would expect to get indexed (so a precise indication which of the array elements has the problem) validation errors:
entities[0].email
entities[1].email
but instead I get:
which clearly does not indicate which exact array element has the problem.
We pinpointed it down to the logic that Type Builder does not set validation metadata for compiled type classes when argument is an array of Input types.
It works fine if argument is something like this:
#[GQL\Input]
class EntityUpdateListInput {
#[GQL\Field(type: '[EntityUpdateInput]!')]
#[Assert\Valid]
public ?array $entities;
}
which is a bit stupid to wrap it unnecessary and have the following mutation:
mutation {
entitiesUpdate(
list: {
entities: [
{
...
email: "invalid1"
}
{
...
email: "invalid2"
}
]
}
)
}
This works fine if those inputs are defined using YAML - the problem is with the PHP attributes.
Having an PHP attribute GQL Input and Provider e.g.
and then having a mutation run like so:
I would expect to get indexed (so a precise indication which of the array elements has the problem) validation errors:
entities[0].emailentities[1].emailbut instead I get:
which clearly does not indicate which exact array element has the problem.
We pinpointed it down to the logic that Type Builder does not set validation metadata for compiled type classes when argument is an array of Input types.
It works fine if argument is something like this:
which is a bit stupid to wrap it unnecessary and have the following mutation:
This works fine if those inputs are defined using YAML - the problem is with the PHP attributes.