WooCommerce Code Reference

ServerConfig
in package

Server configuration class.

Could be passed directly to server constructor. List of options accepted by create method is described in docs.

Usage example:

$config = Automattic\WooCommerce\Vendor\GraphQL\Server\ServerConfig::create()
    ->setSchema($mySchema)
    ->setContext($myContext);

$server = new Automattic\WooCommerce\Vendor\GraphQL\Server\StandardServer($config);
Tags
see
ExecutionResult
see
ServerConfigTest
phpstan-type

PersistedQueryLoader callable(string $queryId, OperationParams $operation): (string|DocumentNode)

phpstan-type

RootValueResolver callable(OperationParams $operation, DocumentNode $doc, string $operationType): mixed

phpstan-type

ValidationRulesOption array|null|callable(OperationParams $operation, DocumentNode $doc, string $operationType): array

phpstan-import-type

ErrorsHandler from ExecutionResult

phpstan-import-type

ErrorFormatter from ExecutionResult

Table of Contents

$context  : mixed|callable
$debugFlag  : int
$errorFormatter  : callable|null
$errorsHandler  : callable|null
$fieldResolver  : callable|null
$persistedQueryLoader  : callable|null
$promiseAdapter  : PromiseAdapter|null
$queryBatching  : bool
$rootValue  : mixed|callable
$schema  : Schema|null
$validationRules  : array<string|int, ValidationRule>|callable|null
create()  : self
Converts an array of options to instance of ServerConfig (or just returns empty config when array is not passed).
getContext()  : mixed|callable
getDebugFlag()  : int
getErrorFormatter()  : callable|null
getErrorsHandler()  : callable|null
getFieldResolver()  : callable|null
getPersistedQueryLoader()  : callable|null
getPromiseAdapter()  : PromiseAdapter|null
getQueryBatching()  : bool
getRootValue()  : mixed|callable
getSchema()  : Schema|null
getValidationRules()  : array<string|int, ValidationRule>|callable|null
setContext()  : self
setDebugFlag()  : self
Set response debug flags.
setErrorFormatter()  : self
setErrorsHandler()  : self
setFieldResolver()  : self
setPersistedQueryLoader()  : self
setPromiseAdapter()  : self
setQueryBatching()  : self
Allow batching queries (disabled by default).
setRootValue()  : self
setSchema()  : self
setValidationRules()  : self
Set validation rules for this server.

Properties

Methods

create()

Converts an array of options to instance of ServerConfig (or just returns empty config when array is not passed).

public static create([array<string, mixed> $config = [] ]) : self
Parameters
$config : array<string, mixed> = []
Tags
throws
InvariantViolation
Return values
self

setDebugFlag()

Set response debug flags.

public setDebugFlag([int $debugFlag = DebugFlag::INCLUDE_DEBUG_MESSAGE ]) : self
Parameters
$debugFlag : int = DebugFlag::INCLUDE_DEBUG_MESSAGE
Tags
see
DebugFlag

class for a list of all available flags

Return values
self

setErrorFormatter()

public setErrorFormatter(callable $errorFormatter) : self
Parameters
$errorFormatter : callable
Tags
phpstan-param

ErrorFormatter $errorFormatter

Return values
self

setPersistedQueryLoader()

public setPersistedQueryLoader(callable|null $persistedQueryLoader) : self
Parameters
$persistedQueryLoader : callable|null
Tags
phpstan-param

PersistedQueryLoader|null $persistedQueryLoader

Return values
self

setQueryBatching()

Allow batching queries (disabled by default).

public setQueryBatching(bool $enableBatching) : self
Parameters
$enableBatching : bool
Return values
self

setRootValue()

public setRootValue(mixed|callable $rootValue) : self
Parameters
$rootValue : mixed|callable
Tags
phpstan-param

mixed|RootValueResolver $rootValue

Return values
self

setValidationRules()

Set validation rules for this server.

public setValidationRules(array<string|int, ValidationRule>|callable|null $validationRules) : self
Parameters
$validationRules : array<string|int, ValidationRule>|callable|null
Tags
phpstan-param

ValidationRulesOption $validationRules

Return values
self