ArrayOf.php
2 months ago
ConnectionOf.php
2 months ago
Deprecated.php
2 months ago
Description.php
2 months ago
Experimental.php
4 weeks ago
HiddenFromMetadataQuery.php
4 weeks ago
Ignore.php
2 months ago
Internal.php
4 weeks ago
Metadata.php
4 weeks ago
Name.php
2 months ago
Parameter.php
2 months ago
ParameterDescription.php
2 months ago
PublicAccess.php
4 weeks ago
RequiredCapability.php
4 weeks ago
ReturnType.php
2 months ago
ScalarType.php
2 months ago
Unroll.php
2 months ago
HiddenFromMetadataQuery.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Automattic\WooCommerce\Api\Attributes; |
| 6 | |
| 7 | use Attribute; |
| 8 | |
| 9 | /** |
| 10 | * Marker attribute that opts a code-API target out of the `_apiMetadata` |
| 11 | * discovery query without affecting any other behaviour. Apply on a |
| 12 | * class (output / input type, query, mutation) or on a property to hide |
| 13 | * that target's row — and all its metadata / authorization descriptors — |
| 14 | * from the `_apiMetadata` endpoint. |
| 15 | * |
| 16 | * This is unrelated to native GraphQL introspection (`__schema` / |
| 17 | * `__type`); those queries continue to expose the schema's shape as |
| 18 | * usual. The marker only affects the custom `_apiMetadata` channel. |
| 19 | * |
| 20 | * The runtime authorization gates emitted into the generated resolvers |
| 21 | * are unaffected: an authorization attribute placed alongside this one |
| 22 | * still runs its `authorize()` method; this marker just removes the |
| 23 | * declarative shape from the discovery channel. |
| 24 | * |
| 25 | * A target's `_apiMetadata` visibility is the AND of every attribute's |
| 26 | * `shows_in_metadata_query()` on the target — so combining |
| 27 | * `#[HiddenFromMetadataQuery]` with any other attribute that returns |
| 28 | * `true` (or none at all) still hides the target. |
| 29 | */ |
| 30 | #[Attribute( Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER | Attribute::TARGET_CLASS_CONSTANT )] |
| 31 | final class HiddenFromMetadataQuery { |
| 32 | /** |
| 33 | * Always returns `false`. ApiBuilder calls this during the per-target |
| 34 | * `_apiMetadata` visibility check; the target is omitted from the |
| 35 | * discovery output as a result. |
| 36 | */ |
| 37 | public function shows_in_metadata_query(): bool { |
| 38 | return false; |
| 39 | } |
| 40 | } |
| 41 |