From beaf91d08089f457c1dac289297f68d03e492a94 Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Sat, 17 Jun 2017 15:01:37 +0200 Subject: [PATCH] Adds example for enabling the DisableIntrospection rule. --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 9036037..a1cc75e 100644 --- a/README.md +++ b/README.md @@ -559,6 +559,24 @@ $queryDepth->setMaxQueryDepth($maxQueryDepth = 10); GraphQL::execute(/*...*/); ``` +#### Disabling Introspection + +This is a PHP port of [graphql-disable-introspection](https://github.com/helfer/graphql-disable-introspection). +The rule prohibits queries that contain `__type` or `__schema` fields. + +This document validator rule is disabled by default. Here an example to enable it: + +```php +use GraphQL\GraphQL; +use GraphQL\Validator\Rules\DisableIntrospection; + +/** @var \GraphQL\Validator\Rules\DisableIntrospection $disableIntrospection */ +$disableIntrospection = DocumentValidator::getRule('DisableIntrospection'); +$disableIntrospection->setEnabled(DisableIntrospection::ENABLED); + +GraphQL::execute(/*...*/); +``` + ### More Examples Make sure to check [tests](https://github.com/webonyx/graphql-php/tree/master/tests) for more usage examples.