StandardServer
in package
Automattic\WooCommerce\Vendor\GraphQL server compatible with both: [express-graphql](https://github.com/graphql/express-graphql) and [Apollo Server](https://github.com/apollographql/graphql-server).
Usage Example:.
$server = new StandardServer([
'schema' => $mySchema
]);
$server->handleRequest();
Or using ServerConfig instance:
$config = Automattic\WooCommerce\Vendor\GraphQL\Server\ServerConfig::create()
->setSchema($mySchema)
->setContext($myContext);
$server = new Automattic\WooCommerce\Vendor\GraphQL\Server\StandardServer($config);
$server->handleRequest();
See dedicated section in docs for details.
Tags
Table of Contents
- $config : ServerConfig
- $helper : Helper
- __construct() : mixed
- executePsrRequest() : ExecutionResult|array<int, ExecutionResult>|Promise
- Executes Automattic\WooCommerce\Vendor\GraphQL operation and returns execution result (or promise when promise adapter is different from SyncPromiseAdapter).
- executeRequest() : ExecutionResult|array<int, ExecutionResult>|Promise
- Executes a Automattic\WooCommerce\Vendor\GraphQL operation and returns an execution result (or promise when promise adapter is different from SyncPromiseAdapter).
- handleRequest() : void
- Parses HTTP request, executes and emits response (using standard PHP `header` function and `echo`).
- processPsrRequest() : ResponseInterface|Promise
- Executes PSR-7 request and fulfills PSR-7 response.
Properties
$config
protected
ServerConfig
$config
$helper
protected
Helper
$helper
Methods
__construct()
public
__construct(ServerConfig|array<string, mixed> $config) : mixed
Parameters
- $config : ServerConfig|array<string, mixed>
Tags
Return values
mixed —executePsrRequest()
Executes Automattic\WooCommerce\Vendor\GraphQL operation and returns execution result (or promise when promise adapter is different from SyncPromiseAdapter).
public
executePsrRequest(RequestInterface $request) : ExecutionResult|array<int, ExecutionResult>|Promise
Parameters
- $request : RequestInterface
Tags
Return values
ExecutionResult|array<int, ExecutionResult>|Promise —executeRequest()
Executes a Automattic\WooCommerce\Vendor\GraphQL operation and returns an execution result (or promise when promise adapter is different from SyncPromiseAdapter).
public
executeRequest([OperationParams|array<string|int, OperationParams> $parsedBody = null ]) : ExecutionResult|array<int, ExecutionResult>|Promise
When $parsedBody is not set, it uses PHP globals to parse a request. It is possible to implement request parsing elsewhere (e.g. using framework Request instance) and then pass it to the server.
PSR-7 compatible method executePsrRequest() does exactly this.
Parameters
- $parsedBody : OperationParams|array<string|int, OperationParams> = null
Tags
Return values
ExecutionResult|array<int, ExecutionResult>|Promise —handleRequest()
Parses HTTP request, executes and emits response (using standard PHP `header` function and `echo`).
public
handleRequest([OperationParams|array<string|int, OperationParams> $parsedBody = null ]) : void
When $parsedBody is not set, it uses PHP globals to parse a request. It is possible to implement request parsing elsewhere (e.g. using framework Request instance) and then pass it to the server.
See executeRequest() if you prefer to emit the response yourself
(e.g. using the Response object of some framework).
Parameters
- $parsedBody : OperationParams|array<string|int, OperationParams> = null
Tags
Return values
void —processPsrRequest()
Executes PSR-7 request and fulfills PSR-7 response.
public
processPsrRequest(RequestInterface $request, ResponseInterface $response, StreamInterface $writableBodyStream) : ResponseInterface|Promise
See executePsrRequest() if you prefer to create response yourself
(e.g. using specific JsonResponse instance of some framework).
Parameters
- $request : RequestInterface
- $response : ResponseInterface
- $writableBodyStream : StreamInterface
