Skip to main content

Reference: recognized methods and parameters

The builder recognizes certain method names on command and attribute classes, and certain specially named parameters that it injects at runtime. These conventions are identical for core and plugins.

Methods on command classes (queries/mutations)

MethodSignatureNotes
executeexecute( ...args ): <return type>Required. Parameters become GraphQL arguments; the return type becomes the GraphQL return type (use #[ReturnType] for interface returns).
authorizeauthorize( ...args ): boolOptional. Custom authorization for the operation; return false to deny. Compose with attributes via $_preauthorized.

Methods on attribute classes

MethodSignatureMakes the attribute…
authorizeauthorize( <PrincipalType> $principal, ... ): boolan authorization attribute.
get_name / get_valueget_name(): string / get_value(): bool|int|float|string|null(on Metadata subclasses) expose the metadata entry.
transform_descriptiontransform_description( string $description ): stringa description-mirroring metadata attribute.
shows_in_metadata_queryshows_in_metadata_query(): boolable to opt its target out of _apiMetadata (when it returns false).

Methods on custom scalar classes

MethodSignaturePurpose
serializestatic serialize( mixed $value ): stringPHP value → transport string.
parsestatic parse( string $value ): mixedClient string → PHP value; throw \InvalidArgumentException on bad input.

Recognized parameters

These are optional, underscore-prefixed parameters detected by name. They may appear in any order; declare only the ones you use. The underscore prefix also keeps them out of the GraphQL argument list. (provided_fields on input types uses the same underscore-invisibility idea for an internal property.)

ParameterTypeAvailable onValue
$_principalthe registered principal typeexecute(), authorize()The resolved principal for the request.
$_preauthorizedboolauthorize() (command)Whether the attribute-based gates already grant access — compose your custom check on top.
$_query_info?arrayexecute()The selection tree of the current query, for resolve-time optimization. Provided via QueryInfoExtractor.
$_metadataarrayauthorize() (attribute)#[Metadata] entries at the call site, in slices ['query'], ['type'], ['field'] (each array<string, scalar>). At the operation level only ['query'] is populated.
$_argsarrayauthorize() (attribute)The GraphQL arguments at the call site.
$_parentmixedauthorize() (attribute)The enclosing object being resolved, for output-field gates (enables owner-or-scope checks).

For how these combine in granular authorization, see Authentication and authorization.

Public PHP-side helpers

CallPurpose
ResolverHelpers::compute_preauthorized( string $command_fqcn, object $principal ): boolAsk whether attribute gates would grant access, without executing the command.
GraphQLControllerBase::get_schema(): SchemaHandleObtain the schema handle for PHP-side metadata inspection.
SchemaHandle::get_all_metadata() / find_metadata( ?name, ?type, ?field )Read collected metadata. See Metadata and discovery.