Closed codedge closed 9 months ago
Mhh looks like a bug but not sure from where it comes (maybe related to https://github.com/api-platform/core/issues/5914 ?). Also you should avoid using input for that can't you declare the Mutation directly on the DTO?
declare the Mutation directly on the DTO
Can you eleborate on that? I don't understand how I should define it diffently to the input
and resolver
inside the entity.
#[GraphQl\Mutation(
resolver: MyCustomResolver::class,
)]
class MyDto {}
I wonder why the id field changes though...
@soyuka I found the place where the id
field disappears. In FieldsBuilder.php
the id
from the input DTO is rewritten to _id
// guess union/intersect types: check each type until finding a valid one
foreach ($propertyTypes as $propertyType) {
if ($fieldConfiguration = $this->getResourceFieldConfiguration($property, $propertyMetadata->getDescription(), $propertyMetadata->getDeprecationReason(), $propertyType, $resourceClass, $input, $operation, $depth, null !== $propertyMetadata->getSecurity())) {
$fields['id' === $property ? '_id' : $this->normalizePropertyName($property, $resourceClass)] = $fieldConfiguration;
// stop at the first valid type
break;
}
}
which was introduced with the 3.2.0 release.
I think, I get the intention behind and it works in all my cases. I just did not see anything about this logic in the docs somethere.
Do you have any additional ideas about this problem? I'm facing the same errors after updating from v3.1.x to v3.2.x
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
API Platform version(s) affected: 3.2.1
Description
When using a custom input dto, that contains an
id
field, this field is not reflected in the generated GraphQL API schema. The other field,someIds
, is properly reflected inside the docs.How to reproduce
Entity
MyCustomDto
Instead, the field
_id
needs to be given as input which is then hydrated into the DTOs fieldid
. See the difference with underscore_
.Possible Solution
Additional Context
I am unsure if this is a bug or some magic. I could live with this change if this would be explained somewhere. To my knowledge this worked differently before and we could pass
_id
and/orid
as fields to a mutation with custom dto.