api-platform / api-platform/core

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

Offen
#3,279 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
GraphQL
Vorherrschende Sprache
PHP
Sterne
2.6k
Forks
980
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
49

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.