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
ScalarType.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Automattic\WooCommerce\Api\Attributes; |
| 6 | |
| 7 | use Attribute; |
| 8 | |
| 9 | /** |
| 10 | * Overrides the GraphQL type for a property with a custom scalar. |
| 11 | * |
| 12 | * By default the builder maps PHP types to built-in GraphQL scalars (String, |
| 13 | * Int, Float, Boolean). Use this attribute when a property should use a custom |
| 14 | * scalar type instead, such as `DateTime`. |
| 15 | * |
| 16 | * Example: `#[ScalarType(DateTime::class)]` on a `?string $date_created` |
| 17 | * property produces the GraphQL type `DateTime` instead of `String`. |
| 18 | */ |
| 19 | #[Attribute] |
| 20 | final class ScalarType { |
| 21 | /** |
| 22 | * Constructor. |
| 23 | * |
| 24 | * @param string $type The fully-qualified class name of the custom scalar |
| 25 | * (e.g. `DateTime::class`). |
| 26 | */ |
| 27 | public function __construct( |
| 28 | public readonly string $type, |
| 29 | ) { |
| 30 | } |
| 31 | } |
| 32 |