Automattic\WooCommerce\Api\Attributes

ScalarType{}finalWC 1.0#[Attribute]

Overrides the GraphQL type for a property with a custom scalar.

By default the builder maps PHP types to built-in GraphQL scalars (String, Int, Float, Boolean). Use this attribute when a property should use a custom scalar type instead, such as DateTime.

Example: #[ScalarType(DateTime::class)] on a ?string $date_created property produces the GraphQL type DateTime instead of String.

No Hooks.

Usage

$ScalarType = new ScalarType();
// use class methods

Methods

  1. public __construct(
  2. ERROR: no method name found on line ``
  3. ERROR: no method name found on line ``
  4. ERROR: no method name found on line ``
  5. ERROR: no method name found on line ``

ScalarType{} code WC 10.9.1

final class ScalarType {
	/**
	 * Constructor.
	 *
	 * @param string $type The fully-qualified class name of the custom scalar
	 *                     (e.g. `DateTime::class`).
	 */
	public function __construct(
		public readonly string $type,
	) {
	}
}