mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 04:46:04 +03:00
Fix CS in src/Server
This commit is contained in:
parent
a95d2ad140
commit
7ba98ce773
@ -17,6 +17,7 @@ use GraphQL\Language\AST\DocumentNode;
|
|||||||
use GraphQL\Language\Parser;
|
use GraphQL\Language\Parser;
|
||||||
use GraphQL\Utils\AST;
|
use GraphQL\Utils\AST;
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
|
use JsonSerializable;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
@ -52,9 +53,11 @@ class Helper
|
|||||||
*
|
*
|
||||||
* For PSR-7 request parsing use `parsePsrRequest()` instead.
|
* For PSR-7 request parsing use `parsePsrRequest()` instead.
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return OperationParams|OperationParams[]
|
* @return OperationParams|OperationParams[]
|
||||||
|
*
|
||||||
* @throws RequestError
|
* @throws RequestError
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function parseHttpRequest(?callable $readRawBodyFn = null)
|
public function parseHttpRequest(?callable $readRawBodyFn = null)
|
||||||
{
|
{
|
||||||
@ -104,12 +107,15 @@ class Helper
|
|||||||
*
|
*
|
||||||
* Returned value is a suitable input for `executeOperation` or `executeBatch` (if array)
|
* Returned value is a suitable input for `executeOperation` or `executeBatch` (if array)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @param mixed[] $bodyParams
|
* @param mixed[] $bodyParams
|
||||||
* @param mixed[] $queryParams
|
* @param mixed[] $queryParams
|
||||||
|
*
|
||||||
* @return OperationParams|OperationParams[]
|
* @return OperationParams|OperationParams[]
|
||||||
|
*
|
||||||
* @throws RequestError
|
* @throws RequestError
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function parseRequestParams($method, array $bodyParams, array $queryParams)
|
public function parseRequestParams($method, array $bodyParams, array $queryParams)
|
||||||
{
|
{
|
||||||
@ -136,8 +142,9 @@ class Helper
|
|||||||
* Checks validity of OperationParams extracted from HTTP request and returns an array of errors
|
* Checks validity of OperationParams extracted from HTTP request and returns an array of errors
|
||||||
* if params are invalid (or empty array when params are valid)
|
* if params are invalid (or empty array when params are valid)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return Error[]
|
* @return Error[]
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function validateOperationParams(OperationParams $params)
|
public function validateOperationParams(OperationParams $params)
|
||||||
{
|
{
|
||||||
@ -185,9 +192,9 @@ class Helper
|
|||||||
* Executes GraphQL operation with given server configuration and returns execution result
|
* Executes GraphQL operation with given server configuration and returns execution result
|
||||||
* (or promise when promise adapter is different from SyncPromiseAdapter)
|
* (or promise when promise adapter is different from SyncPromiseAdapter)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
*
|
|
||||||
* @return ExecutionResult|Promise
|
* @return ExecutionResult|Promise
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function executeOperation(ServerConfig $config, OperationParams $op)
|
public function executeOperation(ServerConfig $config, OperationParams $op)
|
||||||
{
|
{
|
||||||
@ -205,9 +212,11 @@ class Helper
|
|||||||
* Executes batched GraphQL operations with shared promise queue
|
* Executes batched GraphQL operations with shared promise queue
|
||||||
* (thus, effectively batching deferreds|promises of all queries at once)
|
* (thus, effectively batching deferreds|promises of all queries at once)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param OperationParams[] $operations
|
* @param OperationParams[] $operations
|
||||||
|
*
|
||||||
* @return ExecutionResult|ExecutionResult[]|Promise
|
* @return ExecutionResult|ExecutionResult[]|Promise
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function executeBatch(ServerConfig $config, array $operations)
|
public function executeBatch(ServerConfig $config, array $operations)
|
||||||
{
|
{
|
||||||
@ -230,6 +239,7 @@ class Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $isBatch
|
* @param bool $isBatch
|
||||||
|
*
|
||||||
* @return Promise
|
* @return Promise
|
||||||
*/
|
*/
|
||||||
private function promiseToExecuteOperation(
|
private function promiseToExecuteOperation(
|
||||||
@ -252,7 +262,7 @@ class Helper
|
|||||||
if (! empty($errors)) {
|
if (! empty($errors)) {
|
||||||
$errors = Utils::map(
|
$errors = Utils::map(
|
||||||
$errors,
|
$errors,
|
||||||
function (RequestError $err) {
|
static function (RequestError $err) {
|
||||||
return Error::createLocatedError($err, null, null);
|
return Error::createLocatedError($err, null, null);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -294,7 +304,7 @@ class Helper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$applyErrorHandling = function (ExecutionResult $result) use ($config) {
|
$applyErrorHandling = static function (ExecutionResult $result) use ($config) {
|
||||||
if ($config->getErrorsHandler()) {
|
if ($config->getErrorsHandler()) {
|
||||||
$result->setErrorsHandler($config->getErrorsHandler());
|
$result->setErrorsHandler($config->getErrorsHandler());
|
||||||
}
|
}
|
||||||
@ -315,6 +325,7 @@ class Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
* @throws RequestError
|
* @throws RequestError
|
||||||
*/
|
*/
|
||||||
private function loadPersistedQuery(ServerConfig $config, OperationParams $operationParams)
|
private function loadPersistedQuery(ServerConfig $config, OperationParams $operationParams)
|
||||||
@ -341,6 +352,7 @@ class Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $operationType
|
* @param string $operationType
|
||||||
|
*
|
||||||
* @return mixed[]|null
|
* @return mixed[]|null
|
||||||
*/
|
*/
|
||||||
private function resolveValidationRules(
|
private function resolveValidationRules(
|
||||||
@ -368,13 +380,14 @@ class Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $operationType
|
* @param string $operationType
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function resolveRootValue(ServerConfig $config, OperationParams $params, DocumentNode $doc, $operationType)
|
private function resolveRootValue(ServerConfig $config, OperationParams $params, DocumentNode $doc, $operationType)
|
||||||
{
|
{
|
||||||
$root = $config->getRootValue();
|
$root = $config->getRootValue();
|
||||||
|
|
||||||
if ($root instanceof \Closure) {
|
if (is_callable($root)) {
|
||||||
$root = $root($params, $doc, $operationType);
|
$root = $root($params, $doc, $operationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,6 +396,7 @@ class Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $operationType
|
* @param string $operationType
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function resolveContextValue(
|
private function resolveContextValue(
|
||||||
@ -393,7 +407,7 @@ class Helper
|
|||||||
) {
|
) {
|
||||||
$context = $config->getContext();
|
$context = $config->getContext();
|
||||||
|
|
||||||
if ($context instanceof \Closure) {
|
if (is_callable($context)) {
|
||||||
$context = $context($params, $doc, $operationType);
|
$context = $context($params, $doc, $operationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,9 +417,10 @@ class Helper
|
|||||||
/**
|
/**
|
||||||
* Send response using standard PHP `header()` and `echo`.
|
* Send response using standard PHP `header()` and `echo`.
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param Promise|ExecutionResult|ExecutionResult[] $result
|
* @param Promise|ExecutionResult|ExecutionResult[] $result
|
||||||
* @param bool $exitWhenDone
|
* @param bool $exitWhenDone
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function sendResponse($result, $exitWhenDone = false)
|
public function sendResponse($result, $exitWhenDone = false)
|
||||||
{
|
{
|
||||||
@ -425,9 +440,9 @@ class Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed[]|\JsonSerializable $jsonSerializable
|
* @param mixed[]|JsonSerializable $jsonSerializable
|
||||||
* @param int $httpStatus
|
* @param int $httpStatus
|
||||||
* @param bool $exitWhenDone
|
* @param bool $exitWhenDone
|
||||||
*/
|
*/
|
||||||
public function emitResponse($jsonSerializable, $httpStatus, $exitWhenDone)
|
public function emitResponse($jsonSerializable, $httpStatus, $exitWhenDone)
|
||||||
{
|
{
|
||||||
@ -450,6 +465,7 @@ class Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ExecutionResult|mixed[] $result
|
* @param ExecutionResult|mixed[] $result
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function resolveHttpStatus($result)
|
private function resolveHttpStatus($result)
|
||||||
@ -457,7 +473,7 @@ class Helper
|
|||||||
if (is_array($result) && isset($result[0])) {
|
if (is_array($result) && isset($result[0])) {
|
||||||
Utils::each(
|
Utils::each(
|
||||||
$result,
|
$result,
|
||||||
function ($executionResult, $index) {
|
static function ($executionResult, $index) {
|
||||||
if (! $executionResult instanceof ExecutionResult) {
|
if (! $executionResult instanceof ExecutionResult) {
|
||||||
throw new InvariantViolation(sprintf(
|
throw new InvariantViolation(sprintf(
|
||||||
'Expecting every entry of batched query result to be instance of %s but entry at position %d is %s',
|
'Expecting every entry of batched query result to be instance of %s but entry at position %d is %s',
|
||||||
@ -490,9 +506,11 @@ class Helper
|
|||||||
/**
|
/**
|
||||||
* Converts PSR-7 request to OperationParams[]
|
* Converts PSR-7 request to OperationParams[]
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return OperationParams[]|OperationParams
|
* @return OperationParams[]|OperationParams
|
||||||
|
*
|
||||||
* @throws RequestError
|
* @throws RequestError
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function parsePsrRequest(ServerRequestInterface $request)
|
public function parsePsrRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -541,9 +559,11 @@ class Helper
|
|||||||
/**
|
/**
|
||||||
* Converts query execution result to PSR-7 response
|
* Converts query execution result to PSR-7 response
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param Promise|ExecutionResult|ExecutionResult[] $result
|
* @param Promise|ExecutionResult|ExecutionResult[] $result
|
||||||
|
*
|
||||||
* @return Promise|ResponseInterface
|
* @return Promise|ResponseInterface
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function toPsrResponse($result, ResponseInterface $response, StreamInterface $writableBodyStream)
|
public function toPsrResponse($result, ResponseInterface $response, StreamInterface $writableBodyStream)
|
||||||
{
|
{
|
||||||
|
@ -55,10 +55,12 @@ class OperationParams
|
|||||||
/**
|
/**
|
||||||
* Creates an instance from given array
|
* Creates an instance from given array
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param mixed[] $params
|
* @param mixed[] $params
|
||||||
* @param bool $readonly
|
* @param bool $readonly
|
||||||
|
*
|
||||||
* @return OperationParams
|
* @return OperationParams
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public static function create(array $params, $readonly = false)
|
public static function create(array $params, $readonly = false)
|
||||||
{
|
{
|
||||||
@ -97,9 +99,11 @@ class OperationParams
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api
|
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function getOriginalInput($key)
|
public function getOriginalInput($key)
|
||||||
{
|
{
|
||||||
@ -110,8 +114,9 @@ class OperationParams
|
|||||||
* Indicates that operation is executed in read-only context
|
* Indicates that operation is executed in read-only context
|
||||||
* (e.g. via HTTP GET request)
|
* (e.g. via HTTP GET request)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function isReadOnly()
|
public function isReadOnly()
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace GraphQL\Server;
|
namespace GraphQL\Server;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use GraphQL\Error\ClientAware;
|
use GraphQL\Error\ClientAware;
|
||||||
|
|
||||||
class RequestError extends \Exception implements ClientAware
|
class RequestError extends Exception implements ClientAware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns true when exception message is safe to be displayed to client
|
* Returns true when exception message is safe to be displayed to client
|
||||||
|
@ -34,9 +34,11 @@ class ServerConfig
|
|||||||
* Converts an array of options to instance of ServerConfig
|
* Converts an array of options to instance of ServerConfig
|
||||||
* (or just returns empty config when array is not passed).
|
* (or just returns empty config when array is not passed).
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param mixed[] $config
|
* @param mixed[] $config
|
||||||
|
*
|
||||||
* @return ServerConfig
|
* @return ServerConfig
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public static function create(array $config = [])
|
public static function create(array $config = [])
|
||||||
{
|
{
|
||||||
@ -55,10 +57,10 @@ class ServerConfig
|
|||||||
/** @var Schema */
|
/** @var Schema */
|
||||||
private $schema;
|
private $schema;
|
||||||
|
|
||||||
/** @var mixed|\Closure */
|
/** @var mixed|callable */
|
||||||
private $context;
|
private $context;
|
||||||
|
|
||||||
/** @var mixed|\Closure */
|
/** @var mixed|callable */
|
||||||
private $rootValue;
|
private $rootValue;
|
||||||
|
|
||||||
/** @var callable|null */
|
/** @var callable|null */
|
||||||
@ -86,8 +88,9 @@ class ServerConfig
|
|||||||
private $persistentQueryLoader;
|
private $persistentQueryLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api
|
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setSchema(Schema $schema)
|
public function setSchema(Schema $schema)
|
||||||
{
|
{
|
||||||
@ -97,9 +100,11 @@ class ServerConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api
|
* @param mixed|callable $context
|
||||||
* @param mixed|\Closure $context
|
*
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setContext($context)
|
public function setContext($context)
|
||||||
{
|
{
|
||||||
@ -109,9 +114,11 @@ class ServerConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api
|
* @param mixed|callable $rootValue
|
||||||
* @param mixed|\Closure $rootValue
|
*
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setRootValue($rootValue)
|
public function setRootValue($rootValue)
|
||||||
{
|
{
|
||||||
@ -123,8 +130,9 @@ class ServerConfig
|
|||||||
/**
|
/**
|
||||||
* Expects function(Throwable $e) : array
|
* Expects function(Throwable $e) : array
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setErrorFormatter(callable $errorFormatter)
|
public function setErrorFormatter(callable $errorFormatter)
|
||||||
{
|
{
|
||||||
@ -136,8 +144,9 @@ class ServerConfig
|
|||||||
/**
|
/**
|
||||||
* Expects function(array $errors, callable $formatter) : array
|
* Expects function(array $errors, callable $formatter) : array
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setErrorsHandler(callable $handler)
|
public function setErrorsHandler(callable $handler)
|
||||||
{
|
{
|
||||||
@ -149,9 +158,11 @@ class ServerConfig
|
|||||||
/**
|
/**
|
||||||
* Set validation rules for this server.
|
* Set validation rules for this server.
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param ValidationRule[]|callable $validationRules
|
* @param ValidationRule[]|callable $validationRules
|
||||||
|
*
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setValidationRules($validationRules)
|
public function setValidationRules($validationRules)
|
||||||
{
|
{
|
||||||
@ -168,8 +179,9 @@ class ServerConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api
|
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setFieldResolver(callable $fieldResolver)
|
public function setFieldResolver(callable $fieldResolver)
|
||||||
{
|
{
|
||||||
@ -183,8 +195,9 @@ class ServerConfig
|
|||||||
*
|
*
|
||||||
* This function must return query string or valid DocumentNode.
|
* This function must return query string or valid DocumentNode.
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setPersistentQueryLoader(callable $persistentQueryLoader)
|
public function setPersistentQueryLoader(callable $persistentQueryLoader)
|
||||||
{
|
{
|
||||||
@ -196,9 +209,11 @@ class ServerConfig
|
|||||||
/**
|
/**
|
||||||
* Set response debug flags. See GraphQL\Error\Debug class for a list of all available flags
|
* Set response debug flags. See GraphQL\Error\Debug class for a list of all available flags
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param bool|int $set
|
* @param bool|int $set
|
||||||
|
*
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setDebug($set = true)
|
public function setDebug($set = true)
|
||||||
{
|
{
|
||||||
@ -210,9 +225,11 @@ class ServerConfig
|
|||||||
/**
|
/**
|
||||||
* Allow batching queries (disabled by default)
|
* Allow batching queries (disabled by default)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param bool $enableBatching
|
* @param bool $enableBatching
|
||||||
|
*
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setQueryBatching($enableBatching)
|
public function setQueryBatching($enableBatching)
|
||||||
{
|
{
|
||||||
@ -222,8 +239,9 @@ class ServerConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api
|
|
||||||
* @return self
|
* @return self
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function setPromiseAdapter(PromiseAdapter $promiseAdapter)
|
public function setPromiseAdapter(PromiseAdapter $promiseAdapter)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ use GraphQL\Utils\Utils;
|
|||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
use Throwable;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +35,6 @@ use function is_array;
|
|||||||
* $server->handleRequest();
|
* $server->handleRequest();
|
||||||
*
|
*
|
||||||
* See [dedicated section in docs](executing-queries.md#using-server) for details.
|
* See [dedicated section in docs](executing-queries.md#using-server) for details.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class StandardServer
|
class StandardServer
|
||||||
{
|
{
|
||||||
@ -49,10 +49,11 @@ class StandardServer
|
|||||||
* Useful when an exception is thrown somewhere outside of server execution context
|
* Useful when an exception is thrown somewhere outside of server execution context
|
||||||
* (e.g. during schema instantiation).
|
* (e.g. during schema instantiation).
|
||||||
*
|
*
|
||||||
|
* @param Throwable $error
|
||||||
|
* @param bool $debug
|
||||||
|
* @param bool $exitWhenDone
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
* @param \Throwable $error
|
|
||||||
* @param bool $debug
|
|
||||||
* @param bool $exitWhenDone
|
|
||||||
*/
|
*/
|
||||||
public static function send500Error($error, $debug = false, $exitWhenDone = false)
|
public static function send500Error($error, $debug = false, $exitWhenDone = false)
|
||||||
{
|
{
|
||||||
@ -66,8 +67,9 @@ class StandardServer
|
|||||||
/**
|
/**
|
||||||
* Creates new instance of a standard GraphQL HTTP server
|
* Creates new instance of a standard GraphQL HTTP server
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param ServerConfig|mixed[] $config
|
* @param ServerConfig|mixed[] $config
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function __construct($config)
|
public function __construct($config)
|
||||||
{
|
{
|
||||||
@ -91,9 +93,10 @@ class StandardServer
|
|||||||
* See `executeRequest()` if you prefer to emit response yourself
|
* See `executeRequest()` if you prefer to emit response yourself
|
||||||
* (e.g. using Response object of some framework)
|
* (e.g. using Response object of some framework)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param OperationParams|OperationParams[] $parsedBody
|
* @param OperationParams|OperationParams[] $parsedBody
|
||||||
* @param bool $exitWhenDone
|
* @param bool $exitWhenDone
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function handleRequest($parsedBody = null, $exitWhenDone = false)
|
public function handleRequest($parsedBody = null, $exitWhenDone = false)
|
||||||
{
|
{
|
||||||
@ -111,10 +114,13 @@ class StandardServer
|
|||||||
*
|
*
|
||||||
* PSR-7 compatible method executePsrRequest() does exactly this.
|
* PSR-7 compatible method executePsrRequest() does exactly this.
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @param OperationParams|OperationParams[] $parsedBody
|
* @param OperationParams|OperationParams[] $parsedBody
|
||||||
|
*
|
||||||
* @return ExecutionResult|ExecutionResult[]|Promise
|
* @return ExecutionResult|ExecutionResult[]|Promise
|
||||||
|
*
|
||||||
* @throws InvariantViolation
|
* @throws InvariantViolation
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function executeRequest($parsedBody = null)
|
public function executeRequest($parsedBody = null)
|
||||||
{
|
{
|
||||||
@ -135,8 +141,9 @@ class StandardServer
|
|||||||
* See `executePsrRequest()` if you prefer to create response yourself
|
* See `executePsrRequest()` if you prefer to create response yourself
|
||||||
* (e.g. using specific JsonResponse instance of some framework).
|
* (e.g. using specific JsonResponse instance of some framework).
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return ResponseInterface|Promise
|
* @return ResponseInterface|Promise
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function processPsrRequest(
|
public function processPsrRequest(
|
||||||
ServerRequestInterface $request,
|
ServerRequestInterface $request,
|
||||||
@ -151,8 +158,9 @@ class StandardServer
|
|||||||
* Executes GraphQL operation and returns execution result
|
* Executes GraphQL operation and returns execution result
|
||||||
* (or promise when promise adapter is different from SyncPromiseAdapter)
|
* (or promise when promise adapter is different from SyncPromiseAdapter)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return ExecutionResult|ExecutionResult[]|Promise
|
* @return ExecutionResult|ExecutionResult[]|Promise
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function executePsrRequest(ServerRequestInterface $request)
|
public function executePsrRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -164,8 +172,9 @@ class StandardServer
|
|||||||
* Returns an instance of Server helper, which contains most of the actual logic for
|
* Returns an instance of Server helper, which contains most of the actual logic for
|
||||||
* parsing / validating / executing request (which could be re-used by other server implementations)
|
* parsing / validating / executing request (which could be re-used by other server implementations)
|
||||||
*
|
*
|
||||||
* @api
|
|
||||||
* @return Helper
|
* @return Helper
|
||||||
|
*
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
public function getHelper()
|
public function getHelper()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user