public void Validate(IDirectiveContext context) { foreach (InputField argument in context.Field.Arguments) { foreach (IDirective directive in argument.Directives) { object argumentValue = context.Argument <object>(argument.Name); var argumentValidator = directive.ToObject <ArgumentValidationDirective>(); argumentValidator.Validator( context, context.FieldSelection, argument.Name, argumentValue); } } }
// TODO : rework and finalize private static IReadOnlyDictionary <string, object> CreateVariables( IDirectiveContext directiveContext, IEnumerable <SelectionPathComponent> components) { var root = new Dictionary <string, object>(); foreach (var component in components) { foreach (ArgumentNode argument in component.Arguments) { if (argument.Value is ScopedVariableNode sv) { switch (sv.Scope.Value) { case "arguments": root[sv.ToVariableName()] = directiveContext.Argument <object>( sv.Name.Value); break; case "variables": break; case "properties": root[sv.ToVariableName()] = directiveContext .Parent <IDictionary <string, object> >() [sv.Name.Value]; break; default: throw new NotSupportedException(); } } } } return(root); }