public GraphQLHttpMiddleware(
     RequestDelegate next,
     PathString path,
     GraphQLSettings settings,
     IGraphQLRequestDeserializer deserializer,
     IEnumerable <IDocumentExecutionListener> listeners,
     IOptions <GraphQLOptions> options,
     IDocumentWriter writer,
     ILoggerFactory loggerFactory)
 {
     _next         = next;
     _path         = path;
     _deserializer = deserializer;
     _options      = options.Value;
     _listeners    = listeners;
     _settings     = settings;
     _writer       = writer;
     _logger       = loggerFactory.CreateLogger <GraphQLHttpMiddleware <TSchema> >();
 }
Exemple #2
0
        public static void UseGraphQLWithAuth(this IApplicationBuilder app)
        {
            var settings = new GraphQLSettings
            {
                BuildUserContext = ctx =>
                {
                    var userContext = new GraphQLUserContext
                    {
                        User = ctx.User
                    };
                    return userContext;
                }
            };

            var rules = app.ApplicationServices.GetServices<IValidationRule>();
            settings.ValidationRules.AddRange(rules);

            app.UseMiddleware<GraphQLHttpMiddleware<ISchema>>(new PathString("/api/graphql/v1"), settings);
        }