Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules

KnownArgumentNames::getVisitorpublicWC 1.0

Method of the class: KnownArgumentNames{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

KnownArgumentNames::getVisitor() code WC 10.9.1

public function getVisitor(QueryValidationContext $context): array
{
    $knownArgumentNamesOnDirectives = new KnownArgumentNamesOnDirectives();

    return $knownArgumentNamesOnDirectives->getVisitor($context) + [
        NodeKind::ARGUMENT => static function (ArgumentNode $node) use ($context): void {
            $argDef = $context->getArgument();
            if ($argDef !== null) {
                return;
            }

            $fieldDef = $context->getFieldDef();
            if ($fieldDef === null) {
                return;
            }

            $parentType = $context->getParentType();
            if (! $parentType instanceof NamedType) {
                return;
            }

            $context->reportError(new Error(
                static::unknownArgMessage(
                    $node->name->value,
                    $fieldDef->name,
                    $parentType->name,
                    Utils::suggestionList(
                        $node->name->value,
                        array_map(
                            static fn (Argument $arg): string => $arg->name,
                            $fieldDef->args
                        )
                    )
                ),
                [$node]
            ));
        },
    ];
}