public void Configure(ApplicationConfigurationBuilder app)
 {
     app.ConfigureServices(service =>
     {
         service.Configure <SmtpConfig>(app.Configuration.GetSection("Litium:Accelerator:Smtp"));
     });
 }
Esempio n. 2
0
        public void Configure(ApplicationConfigurationBuilder app)
        {
            app.ConfigureServices(services =>
            {
                services.AddCors(options =>
                {
                    options.AddPolicy("DefaultGraphQLCorsPolicy", builder =>
                    {
                        builder.AllowAnyHeader()
                        .WithMethods("GET", "POST")
                        .WithOrigins("http://localhost:3000", "https://localhost", "https://accspa");
                    });
                });

                services.AddSingleton <IDocumentCache>(services =>
                {
                    return(new MemoryDocumentCache(new MemoryDocumentCacheOptions
                    {
                        // maximum total cached query length of 1,000,000 bytes (assume 10x memory usage
                        // for 10MB maximum memory use by the cache)
                        SizeLimit = 1000000,
                        // no expiration of cached queries (cached queries are only ejected when the cache is full)
                        SlidingExpiration = null,
                    }));
                });

                services.AddSingleton <IDocumentExecuter>(services =>
                {
                    return(new DocumentExecuter(
                               new GraphQLDocumentBuilder(),
                               new DocumentValidator(),
                               new ComplexityAnalyzer(),
                               services.GetRequiredService <IDocumentCache>()));
                });

                services.AddSingleton <ISchema, LitiumSchema>();

                services.AddGraphQL(options =>
                {
                    options.EnableMetrics = true;
                })
                .AddErrorInfoProvider(opt => opt.ExposeExceptionStackTrace = true)
                .AddSystemTextJson()
                //.AddUserContextBuilder(httpContext => new GraphQLUserContext { User = httpContext.User })
                ;
            });
        }