Automattic\WooCommerce\Api\Infrastructure
ResolverHelpers::authorize_command
Invoke a command's authorize() method, translating any thrown exceptions into spec-compliant GraphQL errors.
Mirror of execute_command() for the authorize step. Needed because an authorize() call can throw an ApiException (e.g. UnauthorizedException when a target record does not exist); without this wrapper the exception would propagate up to the engine and lose its error code and user-visible message on its way through the generic error formatter.
Method of the class: ResolverHelpers{}
No Hooks.
Returns
true|false. The return value of authorize().
Usage
$result = ResolverHelpers::authorize_command( $command, $authorize_args ): bool;
- $command(object) (required)
- The command instance (must have an authorize() method).
- $authorize_args(array) (required)
- Named arguments to pass to authorize().
ResolverHelpers::authorize_command() ResolverHelpers::authorize command code WC 10.9.1
public static function authorize_command( object $command, array $authorize_args ): bool {
return self::translate_exceptions(
static fn() => $command->authorize( ...$authorize_args )
);
}