public function __invoke(ValidationContext $context)
{
return $this->invokeIfNeeded($context, [NodeKind::OPERATION_DEFINITION => ['leave' => function (OperationDefinitionNode $operationDefinition) use($context) {
$maxDepth = $this->fieldDepth($operationDefinition);
if ($maxDepth > $this->getMaxQueryDepth()) {
$context->reportError(new Error($this->maxQueryDepthErrorMessage($this->getMaxQueryDepth(), $maxDepth)));
}
}]]);
}