api-platform / api-platform/core

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

Open
#3,279 0 comments 0 reactions 0 assignees View on GitHub
GraphQL
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 4h
Merged PRs (30d)
49

Description

**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;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.