api-platform / api-platform/core
[GraphQL] ID field is added although not specified
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 980
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 48
Description
**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**
```php
#[
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**
-
Contributor guide
Assessment
This issue has not been assessed yet.