Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLQueries

ListProducts::resolvepublic staticWC 1.0

Method of the class: ListProducts{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

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

	$query_info                 = QueryInfoExtractor::extract_from_info( $info, $args );
	$execute_args               = array();
	$execute_args['pagination'] = ResolverHelpers::create_pagination_params( $args );
	$execute_args['filters']    = ResolverHelpers::create_input(
		fn() => new \Automattic\WooCommerce\Api\InputTypes\Products\ProductFilterInput(
			status: $args['status'],
			stock_status: $args['stock_status'],
			search: $args['search'] ?? null,
		)
	);
	if ( array_key_exists( 'product_type', $args ) ) {
		$execute_args['product_type'] = $args['product_type'];
	}
	$execute_args['_query_info'] = $query_info;

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

	return $result;
}