Skip to content

Commit beaf91d

Browse files
committed
Adds example for enabling the DisableIntrospection rule.
1 parent 719a438 commit beaf91d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,24 @@ $queryDepth->setMaxQueryDepth($maxQueryDepth = 10);
559559
GraphQL::execute(/*...*/);
560560
```
561561

562+
#### Disabling Introspection
563+
564+
This is a PHP port of [graphql-disable-introspection](https://github.com/helfer/graphql-disable-introspection).
565+
The rule prohibits queries that contain `__type` or `__schema` fields.
566+
567+
This document validator rule is disabled by default. Here an example to enable it:
568+
569+
```php
570+
use GraphQL\GraphQL;
571+
use GraphQL\Validator\Rules\DisableIntrospection;
572+
573+
/** @var \GraphQL\Validator\Rules\DisableIntrospection $disableIntrospection */
574+
$disableIntrospection = DocumentValidator::getRule('DisableIntrospection');
575+
$disableIntrospection->setEnabled(DisableIntrospection::ENABLED);
576+
577+
GraphQL::execute(/*...*/);
578+
```
579+
562580
### More Examples
563581
Make sure to check [tests](https://github.com/webonyx/graphql-php/tree/master/tests) for more usage examples.
564582

0 commit comments

Comments
 (0)