private void ValidateArguments(ITypeCompletionContext context, Directive directive) { Dictionary <string, ArgumentNode> arguments = directive.ToNode().Arguments.ToDictionary(t => t.Name.Value); foreach (ArgumentNode argument in arguments.Values) { if (directive.Type.Arguments.TryGetField( argument.Name.Value, out Argument arg)) { if (!arg.Type.IsInstanceOfType(argument.Value)) { // TODO : resources context.ReportError(SchemaErrorBuilder.New() .SetMessage(string.Format( CultureInfo.InvariantCulture, "The argument `{0}` value type is wrong.", arg.Name)) .SetCode(ErrorCodes.Schema.ArgumentValueTypeWrong) .SetTypeSystemObject(context.Type) .AddSyntaxNode(directive.ToNode()) .SetExtension("Source", _source) .Build()); } } else { // TODO : resources context.ReportError(SchemaErrorBuilder.New() .SetMessage(string.Format( CultureInfo.InvariantCulture, "The argument `{0}` does not exist on the " + "directive `{1}`.", argument.Name.Value, directive.Type.Name)) .SetCode(ErrorCodes.Schema.InvalidArgument) .SetTypeSystemObject(context.Type) .AddSyntaxNode(directive.ToNode()) .SetExtension("Source", _source) .Build()); } } foreach (Argument argument in directive.Type.Arguments .Where(a => a.Type.IsNonNullType())) { if (!arguments.TryGetValue(argument.Name, out ArgumentNode arg) || arg.Value is NullValueNode) { // TODO : resources context.ReportError(SchemaErrorBuilder.New() .SetMessage(string.Format( CultureInfo.InvariantCulture, "The argument `{0}` of directive `{1}` " + "mustn't be null.", argument.Name.Value, directive.Type.Name)) .SetCode(ErrorCodes.Schema.NonNullArgument) .SetTypeSystemObject(context.Type) .AddSyntaxNode(directive.ToNode()) .SetExtension("Source", _source) .Build()); } } }