Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLTypes\Interfaces

ObjectWithId{}WC 1.0

No Hooks.

Usage

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

Methods

  1. public static get()

ObjectWithId{} code WC 10.9.1

class ObjectWithId {
	private static ?InterfaceType $instance = null;

	public static function get(): InterfaceType {
		if ( null === self::$instance ) {
			self::$instance = new InterfaceType(
				array(
					'name'        => 'ObjectWithId',
					'description' => __( 'An object with a numeric ID.', 'woocommerce' ),
					'fields'      => fn() => array(
						'id' => array(
							'type'        => Type::nonNull( Type::int() ),
							'description' => __( 'The unique numeric identifier.', 'woocommerce' ),
						),
					),
					'resolveType' => function ( $value ) {
						$class = get_class( $value );
						$map = array(
							'Automattic\WooCommerce\Api\Types\Coupons\Coupon' => CouponType::get(),
						);
						return $map[ $class ] ?? null;
					},
				)
			);
		}
		return self::$instance;
	}
}