/// <summary> /// Method parameters with the following type are ignored in the schema and will have their value injected: /// <list type="bullet"> /// <item><see cref="IResolveFieldContext"/></item> /// </list> /// </summary> /// <param name="method">Graph endpoint implementation</param> /// <remarks>The method's type must be registered in the <see cref="IServiceCollection"/>.</remarks> /// <returns>The added <see cref="FieldType"/>.</returns> public FieldType AddQuery(MethodMember method) { var handler = !method.Static ? this._ServiceProvider.GetRequiredService(method.Type) : null; var resolver = new MethodFieldResolver(method, handler); return(this.Query.AddField(method.ToFieldType(resolver))); }
/// <summary> /// Method parameters with the following type are ignored in the schema and will have their value injected: /// <list type="bullet"> /// <item><see cref="IResolveFieldContext"/></item> /// </list> /// </summary> /// <typeparam name="T">The class that holds the instance or static method to create a query endpoint from.</typeparam> /// <param name="method">The name of the method or set of methods to use (each method must have a unique GraphName).</param> /// <returns>The added <see cref="FieldType"/>(s).</returns> public FieldType[] AddQuery <T>(string method) where T : class { var methods = TypeOf <T> .Methods[method]; if (methods.Any()) { var handler = methods.Any(method => !method.Static) ? this._ServiceProvider.GetRequiredService <T>() : null; return(methods.To(instanceMethod => { var resolver = new MethodFieldResolver(instanceMethod, handler); return this.Query.AddField(instanceMethod.ToFieldType(resolver)); }).ToArray()); } return(Array <FieldType> .Empty); }