WooCommerce Code Reference

Executor
in package

Implements the "Evaluating requests" section of the Automattic\WooCommerce\Vendor\GraphQL specification.

Tags
phpstan-type

ArgsMapper callable(array<string, mixed>, FieldDefinition, FieldNode, mixed): mixed

phpstan-type

FieldResolver callable(mixed, array<string, mixed>, mixed, ResolveInfo): mixed

phpstan-type

ImplementationFactory callable(PromiseAdapter, Schema, DocumentNode, mixed, mixed, array, ?string, callable, callable): ExecutorImplementation

see
ExecutorTest

Table of Contents

$defaultArgsMapper  : callable
$defaultFieldResolver  : callable
$defaultPromiseAdapter  : PromiseAdapter|null
$implementationFactory  : callable
defaultArgsMapper()  : T
defaultFieldResolver()  : mixed
If a resolve function is not given, then a default resolve behavior is used which takes the property of the root value of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function while passing along args and context.
execute()  : ExecutionResult
Executes DocumentNode against given $schema.
getDefaultArgsMapper()  : callable
getDefaultFieldResolver()  : callable
getDefaultPromiseAdapter()  : PromiseAdapter
getImplementationFactory()  : callable
promiseToExecute()  : Promise
Same as execute(), but requires promise adapter and returns a promise which is always fulfilled with an instance of ExecutionResult and never rejected.
setDefaultArgsMapper()  : void
setDefaultFieldResolver()  : void
Set a custom default resolve function.
setDefaultPromiseAdapter()  : void
Set a custom default promise adapter.
setImplementationFactory()  : void
Set a custom executor implementation factory.

Properties

$implementationFactory

private static callable $implementationFactory = [AutomatticWooCommerceVendorGraphQLExecutorReferenceExecutor::class, 'create']
Tags
phpstan-var

ImplementationFactory

Methods

defaultFieldResolver()

If a resolve function is not given, then a default resolve behavior is used which takes the property of the root value of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function while passing along args and context.

public static defaultFieldResolver(mixed $objectLikeValue, array<string, mixed> $args, mixed $contextValue, ResolveInfo $info) : mixed
Parameters
$objectLikeValue : mixed
$args : array<string, mixed>
$contextValue : mixed
$info : ResolveInfo
Return values
mixed

execute()

Executes DocumentNode against given $schema.

public static execute(Schema $schema, DocumentNode $documentNode[, mixed $rootValue = null ][, mixed $contextValue = null ][, array<string, mixed>|null $variableValues = null ][, string|null $operationName = null ][, callable|null $fieldResolver = null ]) : ExecutionResult

Always returns ExecutionResult and never throws. All errors which occur during operation execution are collected in $result->errors.

Parameters
$schema : Schema
$documentNode : DocumentNode
$rootValue : mixed = null
$contextValue : mixed = null
$variableValues : array<string, mixed>|null = null
$operationName : string|null = null
$fieldResolver : callable|null = null
Tags
phpstan-param

FieldResolver|null $fieldResolver

throws
InvariantViolation
Return values
ExecutionResult

promiseToExecute()

Same as execute(), but requires promise adapter and returns a promise which is always fulfilled with an instance of ExecutionResult and never rejected.

public static promiseToExecute(PromiseAdapter $promiseAdapter, Schema $schema, DocumentNode $documentNode[, mixed $rootValue = null ][, mixed $contextValue = null ][, array<string, mixed>|null $variableValues = null ][, string|null $operationName = null ][, callable|null $fieldResolver = null ][, callable|null $argsMapper = null ]) : Promise

Useful for async PHP platforms.

Parameters
$promiseAdapter : PromiseAdapter
$schema : Schema
$documentNode : DocumentNode
$rootValue : mixed = null
$contextValue : mixed = null
$variableValues : array<string, mixed>|null = null
$operationName : string|null = null
$fieldResolver : callable|null = null
$argsMapper : callable|null = null
Tags
phpstan-param

FieldResolver|null $fieldResolver

phpstan-param

ArgsMapper|null $argsMapper

Return values
Promise

setDefaultArgsMapper()

public static setDefaultArgsMapper(callable $argsMapper) : void
Parameters
$argsMapper : callable
Tags
phpstan-param

ArgsMapper $argsMapper

Return values
void

setDefaultFieldResolver()

Set a custom default resolve function.

public static setDefaultFieldResolver(callable $fieldResolver) : void
Parameters
$fieldResolver : callable
Tags
phpstan-param

FieldResolver $fieldResolver

Return values
void

setImplementationFactory()

Set a custom executor implementation factory.

public static setImplementationFactory(callable $implementationFactory) : void
Parameters
$implementationFactory : callable
Tags
phpstan-param

ImplementationFactory $implementationFactory

Return values
void