public static Task <T> InvokeAsync <T>( this IGraphQLQueryResolver resolver, IResolveFieldContext <object> context, string methodName) { var type = resolver.GetType(); var method = type.GetMethod(methodName); var values = new List <object>(); foreach (var p in method.GetParameters()) { values.Add(context.GetArgument(p.ParameterType, p.Name)); } return((Task <T>)method.Invoke(resolver, values.ToArray())); }
public static void AddFieldToQuery <TFrom, TTo>( this IGraphQLQueryResolver resolver, IObjectGraphType query, string name, string methodName) where TFrom : ObjectGraphType <TTo> { (query as ObjectGraphType) .FieldAsync <ListGraphType <TFrom> >( name, arguments: resolver.GetQueryArguments(methodName), resolve: async context => { return(await resolver.InvokeAsync <IEnumerable <TTo> >(context, methodName)); }); }
public static QueryArguments GetQueryArguments( this IGraphQLQueryResolver resolver, string methodName) { var type = resolver.GetType(); var method = type.GetMethod(methodName); var arguments = new QueryArguments(); foreach (var p in method.GetParameters()) { arguments.Add(new QueryArgument(GetGraphQLType(p.ParameterType)) { Name = p.Name }); } return(arguments); }