<td><strong>Required.</strong> Actual GraphQL query string to be parsed, validated and executed. If you parse query elsewhere before executing - pass corresponding AST document here to avoid new parsing.</td>
<td>Any value that represents a root of your data graph. It is passed as the 1st argument to field resolvers of <ahref="../type-system/schema/#query-and-mutation-types">Query type</a>. Can be omitted or set to null if actual root values are fetched by Query type itself.</td>
<td>Any value that holds information shared between all field resolvers. Most often they use it to pass currently logged in user, locale details, etc.<br><br>It will be available as the 3rd argument in all field resolvers. (see section on <ahref="../type-system/object-types/#field-configuration-options">Field Definitions</a> for reference) <strong>graphql-php</strong> never modifies this value and passes it <em>as is</em> to all underlying resolvers.</td>
<td>Map of variable values passed along with query string. See section on <ahref="http://graphql.org/learn/queries/#variables">query variables on official GraphQL website</a></td>
</tr>
<tr>
<td>operationName</td>
<td><code>string</code></td>
<td>Allows the caller to specify which operation in queryString will be run, in cases where queryString contains multiple top-level operations.</td>
<td>A resolver function to use when one is not provided by the schema. If not provided, the <ahref="../data-fetching/#default-field-resolver">default field resolver is used</a>.</td>
</tr>
<tr>
<td>validationRules</td>
<td><code>array</code></td>
<td>A set of rules for query validation step. The default value is all available rules. Empty array would allow skipping query validation (may be convenient for persisted queries which are validated before persisting and assumed valid during execution)</td>
<p>If you are building HTTP GraphQL API, you may prefer our Standard Server
(compatible with <ahref="https://github.com/graphql/express-graphql">express-graphql</a>).
It supports more features out of the box, including parsing HTTP requests, producing a spec-compliant response; <ahref="#query-batching">batched queries</a>; persisted queries.</p>
<p>Usage example (with plain PHP):</p>
<pre><codeclass="php"><?php
use GraphQL\Server\StandardServer;
$server = new StandardServer([/* server options, see below */]);
$server->handleRequest(); // parses PHP globals and emits response
</code></pre>
<p>Server also supports <ahref="http://www.php-fig.org/psr/psr-7/">PSR-7 request/response interfaces</a>:</p>
<pre><codeclass="php"><?php
use GraphQL\Server\StandardServer;
use GraphQL\Executor\ExecutionResult;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
/** @var ServerRequestInterface $psrRequest */
/** @var ResponseInterface $psrResponse */
/** @var StreamInterface $psrBodyStream */
$server = new StandardServer([/* server options, see below */]);
<td><strong>Required.</strong> Instance of your application <ahref="../type-system/schema/">Schema</a></td>
</tr>
<tr>
<td>rootValue</td>
<td><code>mixed</code></td>
<td>Any value that represents a root of your data graph. It is passed as the 1st argument to field resolvers of <ahref="../type-system/schema/#query-and-mutation-types">Query type</a>. Can be omitted or set to null if actual root values are fetched by Query type itself.</td>
</tr>
<tr>
<td>context</td>
<td><code>mixed</code></td>
<td>Any value that holds information shared between all field resolvers. Most often they use it to pass currently logged in user, locale details, etc.<br><br>It will be available as the 3rd argument in all field resolvers. (see section on <ahref="../type-system/object-types/#field-configuration-options">Field Definitions</a> for reference) <strong>graphql-php</strong> never modifies this value and passes it <em>as is</em> to all underlying resolvers.</td>
</tr>
<tr>
<td>fieldResolver</td>
<td><code>callable</code></td>
<td>A resolver function to use when one is not provided by the schema. If not provided, the <ahref="../data-fetching/#default-field-resolver">default field resolver is used</a>.</td>
</tr>
<tr>
<td>validationRules</td>
<td><code>array</code> or <code>callable</code></td>
<td>A set of rules for query validation step. The default value is all available rules. The empty array would allow skipping query validation (may be convenient for persisted queries which are validated before persisting and assumed valid during execution).<br><br>Pass <code>callable</code> to return different validation rules for different queries (e.g. empty array for persisted query and a full list of rules for regular queries). When passed, it is expected to have the following signature: <br><br><strong>function (<ahref="../reference/#graphqlserveroperationparams">OperationParams</a> $params, DocumentNode $node, $operationType): array</strong></td>
</tr>
<tr>
<td>queryBatching</td>
<td><code>bool</code></td>
<td>Flag indicating whether this server supports query batching (<ahref="https://dev-blog.apollodata.com/query-batching-in-apollo-63acfd859862">apollo-style</a>).<br><br> Defaults to <strong>false</strong></td>
</tr>
<tr>
<td>debug</td>
<td><code>int</code></td>
<td>Debug flags. See <ahref="../error-handling/#debugging-tools">docs on error debugging</a> (flag values are the same).</td>
</tr>
<tr>
<td>persistentQueryLoader</td>
<td><code>callable</code></td>
<td>A function which is called to fetch actual query when server encounters <strong>queryId</strong> in request vs <strong>query</strong>.<br><br> The server does not implement persistence part (which you will have to build on your own), but it allows you to execute queries which were persisted previously.<br><br> Expected function signature:<br><strong>function ($queryId, <ahref="../reference/#graphqlserveroperationparams">OperationParams</a> $params)</strong><br><br>Function is expected to return query <strong>string</strong> or parsed <strong>DocumentNode</strong><br><br><ahref="https://dev-blog.apollodata.com/persisted-graphql-queries-with-apollo-client-119fd7e6bba5">Read more about persisted queries</a>.</td>
</tr>
<tr>
<td>errorFormatter</td>
<td><code>callable</code></td>
<td>Custom error formatter. See <ahref="../error-handling/#custom-error-handling-and-formatting">error handling docs</a>.</td>
</tr>
<tr>
<td>errorsHandler</td>
<td><code>callable</code></td>
<td>Custom errors handler. See <ahref="../error-handling/#custom-error-handling-and-formatting">error handling docs</a>.</td>
Built with <ahref="http://www.mkdocs.org">MkDocs</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.