Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules

QueryDepth::getVisitorpublicWC 1.0

Method of the class: QueryDepth{}

No Hooks.

Returns

null. Nothing (null).

Usage

$QueryDepth = new QueryDepth();
$QueryDepth->getVisitor( $context ): array;
$context(QueryValidationContext) (required)
.

QueryDepth::getVisitor() code WC 10.9.1

public function getVisitor(QueryValidationContext $context): array
{
    return $this->invokeIfNeeded(
        $context,
        [
            NodeKind::OPERATION_DEFINITION => [
                'leave' => function (OperationDefinitionNode $operationDefinition) use ($context): void {
                    $maxDepth = $this->fieldDepth($operationDefinition);

                    if ($maxDepth <= $this->maxQueryDepth) {
                        return;
                    }

                    $context->reportError(
                        new Error(static::maxQueryDepthErrorMessage($this->maxQueryDepth, $maxDepth))
                    );
                },
            ],
        ]
    );
}