public static QueryArguments GetArguments(IGraphQlTypePool graphTypePool, MethodInfo methodInfo) { var result = new List <QueryArgument>(); var parameters = methodInfo.GetParameters(); foreach (var param in parameters) { if (param.ParameterType == typeof(CancellationToken)) { continue; } var argumentNameAttr = param.GetAttribute <ArgumentNameAttribute>(); var argumentDescriptionAttr = param.GetAttribute <ArgumentDescriptionAttribute>(); var isNonNullType = param.GetAttribute <NonNullArgumentAttribute>() != null; var name = argumentNameAttr == null ? param.Name : argumentNameAttr.Name; var description = argumentDescriptionAttr == null ? "" : argumentDescriptionAttr.Description; var graphInputType = isNonNullType ? new NonNullGraphType(graphTypePool.GetInputType(param.ParameterType)) : graphTypePool.GetInputType(param.ParameterType); var argument = new QueryArgument(graphInputType) { Name = name, Description = description, DefaultValue = param.HasDefaultValue ? param.DefaultValue : null }; result.Add(argument); } return(new QueryArguments(result)); }
internal static QueryArguments GetArguments(IGraphQlTypePool graphTypePool, MethodInfo methodInfo) { var result = new List <QueryArgument>(); var parameters = methodInfo.GetParameters(); foreach (var param in parameters) { if (param.ParameterType == typeof(CancellationToken)) { continue; } if (param.GetAttribute <InjectAttribute>() != null) { continue; } var argumentNameAttr = param.GetAttribute <NameAttribute>(); var argumentDescriptionAttr = param.GetAttribute <DescriptionAttribute>(); var isNonNullType = param.GetAttribute <NonNullAttribute>() != null; var name = argumentNameAttr == null ? param.Name : argumentNameAttr.Name; var description = argumentDescriptionAttr?.Description ?? DocXmlHelper.DocReader.GetMethodComments(methodInfo)?.Parameters.FirstOrDefault(x => x.Name == param.Name).Text; var graphInputType = isNonNullType ? new NonNullGraphType(graphTypePool.GetInputType(param.ParameterType)) : graphTypePool.GetInputType(param.ParameterType); var argument = new QueryArgument(graphInputType) { Name = name, Description = description, DefaultValue = param.HasDefaultValue ? param.DefaultValue : null }; result.Add(argument); } return(new QueryArguments(result)); }