public function __invoke(ValidationContext $context) { return [Node::ARGUMENT => function (Argument $node) use($context) { $fieldDef = $context->getFieldDef(); if ($fieldDef) { $argDef = null; foreach ($fieldDef->args as $arg) { if ($arg->name === $node->name->value) { $argDef = $arg; break; } } if (!$argDef) { $parentType = $context->getParentType(); Utils::invariant($parentType); return new Error(Messages::unknownArgMessage($node->name->value, $fieldDef->name, $parentType->name), [$node]); } } }]; }
private function unknownArg($argName, $fieldName, $typeName, $line, $column) { return new FormattedError(Messages::unknownArgMessage($argName, $fieldName, $typeName), [new SourceLocation($line, $column)]); }