Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLQueries

GetCoupon::resolvepublic staticWC 1.0

Method of the class: GetCoupon{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = GetCoupon::resolve( $root, $args, $context, $info ): mixed;
$root(mixed) (required)
.
$args(array) (required)
.
$context(mixed) (required)
.
$info(ResolveInfo) (required)
.

GetCoupon::resolve() code WC 10.9.1

public static function resolve( mixed $root, array $args, mixed $context, ResolveInfo $info ): mixed {
	// Standalone authorization gate: no authorize() method on the command,
	// so the autodiscovered authorization attributes are the sole guard.
	if ( ! self::compute_preauthorized( $context['principal'] ) ) {
		throw ResolverHelpers::build_authorization_error( $context['principal'] );
	}

	// Publish the root query's metadata so downstream field-level
	// authorization gates can read it via `$_metadata['query']`.
	// $context is an ArrayObject (see GraphQLController::process_request())
	// so the mutation propagates to nested resolvers.
	$context['_query_metadata'] = array();

	$command = \Automattic\WooCommerce\Api\Infrastructure\ClassResolver::resolve_class( GetCouponCommand::class );

	$execute_args = array();
	if ( array_key_exists( 'id', $args ) ) {
		$execute_args['id'] = $args['id'];
	}
	if ( array_key_exists( 'code', $args ) ) {
		$execute_args['code'] = $args['code'];
	}

	$result = ResolverHelpers::execute_command( $command, $execute_args );

	return $result;
}