Deployed 012082d with MkDocs version: 1.0.4

This commit is contained in:
Vladimir Razuvaev 2018-11-27 20:10:17 +07:00
parent 7ba7654e32
commit cc56df0bb0
11 changed files with 585 additions and 389 deletions

View File

@ -8,7 +8,7 @@
<link rel="shortcut icon" href="../img/favicon.ico"> <link rel="shortcut icon" href="../img/favicon.ico">
<title>Type Registry - graphql-php</title> <title>Config Validation - graphql-php</title>
<link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../css/theme.css" type="text/css" /> <link rel="stylesheet" href="../css/theme.css" type="text/css" />
@ -17,7 +17,7 @@
<script> <script>
// Current page data // Current page data
var mkdocs_page_name = "Type Registry"; var mkdocs_page_name = "Config Validation";
var mkdocs_page_input_path = "best-practices.md"; var mkdocs_page_input_path = "best-practices.md";
var mkdocs_page_url = null; var mkdocs_page_url = null;
</script> </script>
@ -166,7 +166,7 @@
<li>Type Registry</li> <li>Config Validation</li>
<li class="wy-breadcrumbs-aside"> <li class="wy-breadcrumbs-aside">
</li> </li>
@ -176,7 +176,14 @@
<div role="main"> <div role="main">
<div class="section"> <div class="section">
<h1 id="type-registry">Type Registry</h1> <h1 id="config-validation">Config Validation</h1>
<p>Defining types using arrays may be error-prone, but <strong>graphql-php</strong> provides config validation
tool to report when config has unexpected structure. </p>
<p>This validation tool is <strong>disabled by default</strong> because it is time-consuming operation which only
makes sense during development.</p>
<p>To enable validation - call: <code>GraphQL\Type\Definition\Config::enableValidation();</code> in your bootstrap
but make sure to restrict it to debug/development mode only.</p>
<h1 id="type-registry">Type Registry</h1>
<p><strong>graphql-php</strong> expects that each type in Schema is presented by single instance. Therefore <p><strong>graphql-php</strong> expects that each type in Schema is presented by single instance. Therefore
if you define your types as separate PHP classes you need to ensure that each type is referenced only once.</p> if you define your types as separate PHP classes you need to ensure that each type is referenced only once.</p>
<p>Technically you can create several instances of your type (for example for tests), but <code>GraphQL\Type\Schema</code> <p>Technically you can create several instances of your type (for example for tests), but <code>GraphQL\Type\Schema</code>

View File

@ -209,6 +209,7 @@
<li><a href="https://chrome.google.com/webstore/detail/chromeiql/fkkiamalmpiidkljmicmjfbieiclmeij">ChromeiQL</a> <li><a href="https://chrome.google.com/webstore/detail/chromeiql/fkkiamalmpiidkljmicmjfbieiclmeij">ChromeiQL</a>
or <a href="https://chrome.google.com/webstore/detail/graphiql-feen/mcbfdonlkfpbfdpimkjilhdneikhfklp">GraphiQL Feen</a> - or <a href="https://chrome.google.com/webstore/detail/graphiql-feen/mcbfdonlkfpbfdpimkjilhdneikhfklp">GraphiQL Feen</a> -
GraphiQL as Google Chrome extension</li> GraphiQL as Google Chrome extension</li>
<li><a href="https://github.com/prismagraphql/graphql-playground">GraphQL Playground</a> - GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs &amp; collaboration).</li>
</ul> </ul>
</div> </div>

View File

@ -298,7 +298,7 @@ function defaultFieldResolver($source, $args, $context, \GraphQL\Type\Definition
} }
} }
return $property instanceof \Closure ? $property($source, $args, $context) : $property; return $property instanceof Closure ? $property($source, $args, $context, $info) : $property;
} }
</code></pre> </code></pre>

View File

@ -296,7 +296,7 @@ $result = GraphQL::executeQuery(/*args*/)-&gt;toArray($debug);
]; ];
</code></pre> </code></pre>
<p>If you prefer first resolver exception to be re-thrown, use following flags:</p> <p>If you prefer the first resolver exception to be re-thrown, use following flags:</p>
<pre><code class="php">&lt;?php <pre><code class="php">&lt;?php
use GraphQL\GraphQL; use GraphQL\GraphQL;
use GraphQL\Error\Debug; use GraphQL\Error\Debug;
@ -306,6 +306,8 @@ $debug = Debug::INCLUDE_DEBUG_MESSAGE | Debug::RETHROW_INTERNAL_EXCEPTIONS;
$result = GraphQL::executeQuery(/*args*/)-&gt;toArray($debug); $result = GraphQL::executeQuery(/*args*/)-&gt;toArray($debug);
</code></pre> </code></pre>
<p>If you only want to re-throw Exceptions that are not marked as safe through the <code>ClientAware</code> interface, use
the flag <code>Debug::RETHROW_UNSAFE_EXCEPTIONS</code>.</p>
<h1 id="custom-error-handling-and-formatting">Custom Error Handling and Formatting</h1> <h1 id="custom-error-handling-and-formatting">Custom Error Handling and Formatting</h1>
<p>It is possible to define custom <strong>formatter</strong> and <strong>handler</strong> for result errors.</p> <p>It is possible to define custom <strong>formatter</strong> and <strong>handler</strong> for result errors.</p>
<p><strong>Formatter</strong> is responsible for converting instances of <a href="../reference/#graphqlerrorerror"><code>GraphQL\Error\Error</code></a> <p><strong>Formatter</strong> is responsible for converting instances of <a href="../reference/#graphqlerrorerror"><code>GraphQL\Error\Error</code></a>

View File

@ -201,7 +201,7 @@
<p>This documentation assumes your familiarity with GraphQL concepts. If it is not the case - <p>This documentation assumes your familiarity with GraphQL concepts. If it is not the case -
first learn about GraphQL on <a href="http://graphql.org/learn/">the official website</a>.</p> first learn about GraphQL on <a href="http://graphql.org/learn/">the official website</a>.</p>
<h1 id="installation">Installation</h1> <h1 id="installation">Installation</h1>
<p>Using <a href="https://getcomposer.org/doc/00-intro.md">composer</a>, simply run:</p> <p>Using <a href="https://getcomposer.org/doc/00-intro.md">composer</a>, run:</p>
<pre><code class="sh">composer require webonyx/graphql-php <pre><code class="sh">composer require webonyx/graphql-php
</code></pre> </code></pre>

View File

@ -283,5 +283,5 @@ as well as some experimental features like
<!-- <!--
MkDocs version : 1.0.4 MkDocs version : 1.0.4
Build Date UTC : 2018-11-27 13:09:01 Build Date UTC : 2018-11-27 13:10:16
--> -->

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -285,10 +285,11 @@ class EmailType extends ScalarType
* } * }
* *
* @param \GraphQL\Language\AST\Node $valueNode * @param \GraphQL\Language\AST\Node $valueNode
* @param array|null $variables
* @return string * @return string
* @throws Error * @throws Error
*/ */
public function parseLiteral($valueNode) public function parseLiteral($valueNode, array $variables = null)
{ {
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL // Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
// error location in query: // error location in query:
@ -311,7 +312,7 @@ $emailType = new CustomScalarType([
'name' =&gt; 'Email', 'name' =&gt; 'Email',
'serialize' =&gt; function($value) {/* See function body above */}, 'serialize' =&gt; function($value) {/* See function body above */},
'parseValue' =&gt; function($value) {/* See function body above */}, 'parseValue' =&gt; function($value) {/* See function body above */},
'parseLiteral' =&gt; function($valueNode) {/* See function body above */}, 'parseLiteral' =&gt; function($valueNode, array $variables = null) {/* See function body above */},
]); ]);
</code></pre> </code></pre>

View File

@ -115,6 +115,9 @@
<li class="toctree-l3"><a href="#defining-your-schema">Defining your schema</a></li> <li class="toctree-l3"><a href="#defining-your-schema">Defining your schema</a></li>
<li class="toctree-l3"><a href="#defining-resolvers">Defining resolvers</a></li>
<li class="toctree-l3"><a href="#performance-considerations">Performance considerations</a></li> <li class="toctree-l3"><a href="#performance-considerations">Performance considerations</a></li>
@ -221,6 +224,26 @@ $schema = BuildSchema::build($contents);
<p>By default, such schema is created without any resolvers.</p> <p>By default, such schema is created without any resolvers.</p>
<p>We have to rely on <a href="../../data-fetching/#default-field-resolver">default field resolver</a> and <strong>root value</strong> in <p>We have to rely on <a href="../../data-fetching/#default-field-resolver">default field resolver</a> and <strong>root value</strong> in
order to execute a query against this schema.</p> order to execute a query against this schema.</p>
<h1 id="defining-resolvers">Defining resolvers</h1>
<p>Since 0.10.0</p>
<p>In order to enable <strong>Interfaces</strong>, <strong>Unions</strong> and custom field resolvers you can pass the second argument:
<strong>type config decorator</strong> to schema builder.</p>
<p>It accepts default type config produced by the builder and is expected to add missing options like
<a href="../interfaces/#configuration-options"><strong>resolveType</strong></a> for interface types or
<a href="../object-types/#configuration-options"><strong>resolveField</strong></a> for object types.</p>
<pre><code class="php">&lt;?php
use GraphQL\Utils\BuildSchema;
$typeConfigDecorator = function($typeConfig, $typeDefinitionNode) {
$name = $typeConfig['name'];
// ... add missing options to $typeConfig based on type $name
return $typeConfig;
};
$contents = file_get_contents('schema.graphql');
$schema = BuildSchema::build($contents, $typeConfigDecorator);
</code></pre>
<h1 id="performance-considerations">Performance considerations</h1> <h1 id="performance-considerations">Performance considerations</h1>
<p>Since 0.10.0</p> <p>Since 0.10.0</p>
<p>Method <strong>build()</strong> produces a <a href="../schema/#lazy-loading-of-types">lazy schema</a> <p>Method <strong>build()</strong> produces a <a href="../schema/#lazy-loading-of-types">lazy schema</a>