Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules

NoFragmentCycles::getVisitorpublicWC 1.0

Method of the class: NoFragmentCycles{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

NoFragmentCycles::getVisitor() code WC 10.9.1

public function getVisitor(QueryValidationContext $context): array
{
    // Tracks already visited fragments to maintain O(N) and to ensure that cycles
    // are not redundantly reported.
    $this->visitedFrags = [];

    // Array of AST nodes used to produce meaningful errors
    $this->spreadPath = [];

    // Position in the spread path
    $this->spreadPathIndexByName = [];

    return [
        NodeKind::OPERATION_DEFINITION => static fn (): VisitorOperation => Visitor::skipNode(),
        NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context): VisitorOperation {
            $this->detectCycleRecursive($node, $context);

            return Visitor::skipNode();
        },
    ];
}