GraphQL\Validator\Rules\KnownArgumentNames::__invoke PHP Метод

__invoke() публичный Метод

public __invoke ( ValidationContext $context )
$context GraphQL\Validator\ValidationContext
    public function __invoke(ValidationContext $context)
    {
        return [NodeKind::ARGUMENT => function (ArgumentNode $node, $key, $parent, $path, $ancestors) use($context) {
            $argumentOf = $ancestors[count($ancestors) - 1];
            if ($argumentOf->kind === NodeKind::FIELD) {
                $fieldDef = $context->getFieldDef();
                if ($fieldDef) {
                    $fieldArgDef = null;
                    foreach ($fieldDef->args as $arg) {
                        if ($arg->name === $node->name->value) {
                            $fieldArgDef = $arg;
                            break;
                        }
                    }
                    if (!$fieldArgDef) {
                        $parentType = $context->getParentType();
                        Utils::invariant($parentType);
                        $context->reportError(new Error(self::unknownArgMessage($node->name->value, $fieldDef->name, $parentType->name), [$node]));
                    }
                }
            } else {
                if ($argumentOf->kind === NodeKind::DIRECTIVE) {
                    $directive = $context->getDirective();
                    if ($directive) {
                        $directiveArgDef = null;
                        foreach ($directive->args as $arg) {
                            if ($arg->name === $node->name->value) {
                                $directiveArgDef = $arg;
                                break;
                            }
                        }
                        if (!$directiveArgDef) {
                            $context->reportError(new Error(self::unknownDirectiveArgMessage($node->name->value, $directive->name), [$node]));
                        }
                    }
                }
            }
        }];
    }