core
core copied to clipboard
[GraphQL] ID field is added although not specified
API Platform version(s) affected: 3.1.2
Description
When defining a new type, an ID field is automatically added to the generate schema. This should not be the case.
How to reproduce
Take the following entity as example:
Entity
#[
API\ApiResource(
graphQlOperations: [
new Query(
args: [],
),
]
)
]
class Service
{
#[
API\ApiProperty(identifier: true),
Assert\NotNull,
]
private string $name = "abc-123";
#[
Assert\NotNull,
]
private string $version = "0.1.0";
#[
Assert\NotNull,
]
private string $schema = "";
// .. getter/setter
}
This generates the following schema

As you can see, the ID is in the schema but it is not defined. An external service is checking this schema, and does not allow this field to be there.
Possible Solution
A new type can be configure to not implement the Node interface. That is where the id fiel is coming from.
Additional Context
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.
Bump
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.
Bump
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.
Bump
I don't see where this has been merged. Why has this been closed?
Because of how our internals are working I guess we always need an id:ID ? this is probably fixable feel free to open a patch