Automattic\WooCommerce\Internal\Api\Autogenerated\GraphQLQueries
ListCoupons::resolve
Method of the class: ListCoupons{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = ListCoupons::resolve( $root, $args, $context, $info ): mixed;
- $root(mixed) (required)
- .
- $args(array) (required)
- .
- $context(mixed) (required)
- .
- $info(ResolveInfo) (required)
- .
ListCoupons::resolve() ListCoupons::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( ListCouponsCommand::class );
$execute_args = array();
$execute_args['pagination'] = ResolverHelpers::create_pagination_params( $args );
if ( array_key_exists( 'status', $args ) ) {
$execute_args['status'] = $args['status'];
}
$result = ResolverHelpers::execute_command( $command, $execute_args );
return $result;
}