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 天 2 小时
30 天内合并 PR
51

描述

**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 摘要。