setEnabled($enabled); } public function setEnabled($enabled) { $this->isEnabled = $enabled; } static function introspectionDisabledMessage() { return 'GraphQL introspection is not allowed, but the query contained __schema or __type'; } protected function isEnabled() { return $this->isEnabled !== static::DISABLED; } public function getVisitor(ValidationContext $context) { return $this->invokeIfNeeded( $context, [ NodeKind::FIELD => function (FieldNode $node) use ($context) { if ($node->name->value === '__type' || $node->name->value === '__schema') { $context->reportError(new Error( static::introspectionDisabledMessage(), [$node] )); } } ] ); } }