public GraphQLMiddleware( RequestDelegate next, GraphQLSettings settings, IDocumentExecuter executer, IDocumentWriter writer) { _next = next; _settings = settings; _executer = executer; _writer = writer; }
public static void UseGraphQLWithAuth(this IApplicationBuilder app) { var settings = new GraphQLSettings { BuildUserContext = ctx => { var principalProvider = app.ApplicationServices.GetService <IHttpContextAccessor>(); var principal = principalProvider.HttpContext.User; var userContext = new GraphQLUserContext { User = ctx.User }; return(userContext); } }; var rules = app.ApplicationServices.GetServices <IValidationRule>(); settings.ValidationRules.AddRange(rules); app.UseMiddleware <GraphQLMiddleware>(settings); }