WooCommerce Code Reference

Type.php

Source code

<?php

declare(strict_types=1);

namespace Automattic\WooCommerce\Api\Infrastructure\Schema;

use Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type as WebonyxType;

/**
 * Static facade for GraphQL scalar types and type modifiers referenced by
 * autogenerated resolvers.
 *
 * Autogenerated code emitted by ApiBuilder only touches the underlying
 * GraphQL engine through this (and the other classes in the
 * Api\Infrastructure\Schema namespace), so the engine can be swapped without
 * invalidating already-committed generated code. Return types are
 * intentionally omitted so a future migration can change the concrete
 * return type without breaking callers.
 */
final class Type {
	/**
	 * The built-in GraphQL Int scalar.
	 */
	public static function int() {
		return WebonyxType::int();
	}

	/**
	 * The built-in GraphQL String scalar.
	 */
	public static function string() {
		return WebonyxType::string();
	}

	/**
	 * The built-in GraphQL Boolean scalar.
	 */
	public static function boolean() {
		return WebonyxType::boolean();
	}

	/**
	 * The built-in GraphQL Float scalar.
	 */
	public static function float() {
		return WebonyxType::float();
	}

	/**
	 * The built-in GraphQL ID scalar.
	 */
	public static function id() {
		return WebonyxType::id();
	}

	// phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid -- Method names mirror the webonyx Type factories so autogenerated imports of this facade and its webonyx counterpart are interchangeable.

	/**
	 * Wrap a nullable schema type as non-null (`T!`).
	 *
	 * @param mixed $inner A nullable schema type.
	 */
	public static function nonNull( $inner ) {
		return WebonyxType::nonNull( $inner );
	}

	/**
	 * Wrap a schema type as a list (`[T]`).
	 *
	 * @param mixed $inner A schema type.
	 */
	public static function listOf( $inner ) {
		return WebonyxType::listOf( $inner );
	}

	// phpcs:enable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
}