GraphQL\Validator\Rules\NoFragmentCycles::__invoke PHP Method

__invoke() public method

public __invoke ( ValidationContext $context )
$context GraphQL\Validator\ValidationContext
    public function __invoke(ValidationContext $context)
    {
        // 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 => function () {
            return Visitor::skipNode();
        }, NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use($context) {
            if (!isset($this->visitedFrags[$node->name->value])) {
                $this->detectCycleRecursive($node, $context);
            }
            return Visitor::skipNode();
        }];
    }