Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLMutations

DeleteProduct::resolvepublic staticWC 1.0

Method of the class: DeleteProduct{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

DeleteProduct::resolve() code WC 10.9.4

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( DeleteProductCommand::class );

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

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

	return array( 'result' => $result );
}