mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 04:46:04 +03:00
Deployed 012082d
with MkDocs version: 1.0.4
This commit is contained in:
parent
7ba7654e32
commit
cc56df0bb0
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
<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 rel="stylesheet" href="../css/theme.css" type="text/css" />
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
<script>
|
||||
// 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_url = null;
|
||||
</script>
|
||||
@ -166,7 +166,7 @@
|
||||
|
||||
|
||||
|
||||
<li>Type Registry</li>
|
||||
<li>Config Validation</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
</li>
|
||||
@ -176,6 +176,13 @@
|
||||
<div role="main">
|
||||
<div class="section">
|
||||
|
||||
<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
|
||||
if you define your types as separate PHP classes you need to ensure that each type is referenced only once.</p>
|
||||
|
@ -209,6 +209,7 @@
|
||||
<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> -
|
||||
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 & collaboration).</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
@ -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>
|
||||
|
||||
|
@ -296,7 +296,7 @@ $result = GraphQL::executeQuery(/*args*/)->toArray($debug);
|
||||
];
|
||||
</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"><?php
|
||||
use GraphQL\GraphQL;
|
||||
use GraphQL\Error\Debug;
|
||||
@ -306,6 +306,8 @@ $debug = Debug::INCLUDE_DEBUG_MESSAGE | Debug::RETHROW_INTERNAL_EXCEPTIONS;
|
||||
$result = GraphQL::executeQuery(/*args*/)->toArray($debug);
|
||||
</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>
|
||||
<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>
|
||||
|
@ -201,7 +201,7 @@
|
||||
<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>
|
||||
<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
|
||||
</code></pre>
|
||||
|
||||
|
@ -283,5 +283,5 @@ as well as some experimental features like
|
||||
|
||||
<!--
|
||||
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
BIN
sitemap.xml.gz
BIN
sitemap.xml.gz
Binary file not shown.
@ -285,10 +285,11 @@ class EmailType extends ScalarType
|
||||
* }
|
||||
*
|
||||
* @param \GraphQL\Language\AST\Node $valueNode
|
||||
* @param array|null $variables
|
||||
* @return string
|
||||
* @throws Error
|
||||
*/
|
||||
public function parseLiteral($valueNode)
|
||||
public function parseLiteral($valueNode, array $variables = null)
|
||||
{
|
||||
// Note: throwing GraphQL\Error\Error vs \UnexpectedValueException to benefit from GraphQL
|
||||
// error location in query:
|
||||
@ -311,7 +312,7 @@ $emailType = new CustomScalarType([
|
||||
'name' => 'Email',
|
||||
'serialize' => function($value) {/* See function body above */},
|
||||
'parseValue' => function($value) {/* See function body above */},
|
||||
'parseLiteral' => function($valueNode) {/* See function body above */},
|
||||
'parseLiteral' => function($valueNode, array $variables = null) {/* See function body above */},
|
||||
]);
|
||||
</code></pre>
|
||||
|
||||
|
@ -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-resolvers">Defining resolvers</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>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>
|
||||
<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"><?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>
|
||||
<p>Since 0.10.0</p>
|
||||
<p>Method <strong>build()</strong> produces a <a href="../schema/#lazy-loading-of-types">lazy schema</a>
|
||||
|
Loading…
Reference in New Issue
Block a user