Documentation

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 = GraphQL\Server\ServerConfig::create()
    ->setSchema($mySchema)
    ->setContext($myContext);

$server = new GraphQL\Server\StandardServer($config);

Table of Contents

$context  : mixed|callable
$debugFlag  : int
$errorFormatter  : callable|null
$errorsHandler  : callable|null
$fieldResolver  : callable|null
$persistentQueryLoader  : callable|null
$promiseAdapter  : PromiseAdapter|null
$queryBatching  : bool
$rootValue  : mixed|callable
$schema  : Schema|null
$validationRules  : array<string|int, ValidationRule>|callable|null
create()  : ServerConfig
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
getPersistentQueryLoader()  : 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
Expects function(Throwable $e) : array
setErrorsHandler()  : self
Expects function(array $errors, callable $formatter) : array
setFieldResolver()  : self
setPersistentQueryLoader()  : self
Expects function($queryId, OperationParams $params) : string|DocumentNode
setPromiseAdapter()  : self
setQueryBatching()  : self
Allow batching queries (disabled by default)
setRootValue()  : self
setSchema()  : self
setValidationRules()  : self
Set validation rules for this server.

Properties

$debugFlag

private int $debugFlag = \GraphQL\Error\DebugFlag::NONE

$persistentQueryLoader

private callable|null $persistentQueryLoader

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|int, mixed> $config = [] ]) : ServerConfig
Parameters
$config : array<string|int, mixed> = []
Return values
ServerConfig

getContext()

public getContext() : mixed|callable
Return values
mixed|callable

getDebugFlag()

public getDebugFlag() : int
Return values
int

getErrorFormatter()

public getErrorFormatter() : callable|null
Return values
callable|null

getErrorsHandler()

public getErrorsHandler() : callable|null
Return values
callable|null

getFieldResolver()

public getFieldResolver() : callable|null
Return values
callable|null

getPersistentQueryLoader()

public getPersistentQueryLoader() : callable|null
Return values
callable|null

getQueryBatching()

public getQueryBatching() : bool
Return values
bool

getRootValue()

public getRootValue() : mixed|callable
Return values
mixed|callable

getSchema()

public getSchema() : Schema|null
Return values
Schema|null

setContext()

public setContext(mixed|callable $context) : self
Parameters
$context : mixed|callable
Return values
self

setDebugFlag()

Set response debug flags.

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

@see \GraphQL\Error\DebugFlag class for a list of all available flags

Parameters
$debugFlag : int = DebugFlag::INCLUDE_DEBUG_MESSAGE
Return values
self

setErrorFormatter()

Expects function(Throwable $e) : array

public setErrorFormatter(callable $errorFormatter) : self
Parameters
$errorFormatter : callable
Return values
self

setErrorsHandler()

Expects function(array $errors, callable $formatter) : array

public setErrorsHandler(callable $handler) : self
Parameters
$handler : callable
Return values
self

setFieldResolver()

public setFieldResolver(callable $fieldResolver) : self
Parameters
$fieldResolver : callable
Return values
self

setPersistentQueryLoader()

Expects function($queryId, OperationParams $params) : string|DocumentNode

public setPersistentQueryLoader(callable $persistentQueryLoader) : self

This function must return query string or valid DocumentNode.

Parameters
$persistentQueryLoader : callable
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
Return values
self

setSchema()

public setSchema(Schema $schema) : self
Parameters
$schema : Schema
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
Return values
self

Search results