api-platform / api-platform/core

[GraphQL] ID field is added although not specified

未關閉
#5,461 8 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
PHP
星號
2.6k
分支
980
平均合併
2 天 5 小時
30 天內合併 PR
48

描述

**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

![2023-03-15_13 55 46](https://user-images.githubusercontent.com/4409904/225315178-5212afaf-925b-4517-bccc-b8a105b46be8.png)

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**
-

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。