api-platform / api-platform/core

[GraphQL] Add a `visibily` attribute in `ApiProperty` to hide fields depending on the context

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

描述

**Description**
The PR https://github.com/api-platform/core/pull/3227 has added a `security` attribute in `ApiProperty` for not using a property if it is not allowed.

If the user wants to hide the field completely from the GraphQL schema, we could introduce a `visibility` attribute like GraphQL Ruby does (https://graphql-ruby.org/authorization/visibility).

For REST, it could have the same effect as the `security` attribute.

**Example**
```php
class Offer
{
/**
* @var string The dummy secret property, only readable/writable by specific users
*
* @ApiProperty(visibility="is_granted('ROLE_ADMIN')")
*/
private $adminOnlyProperty;
}
```

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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