<commit_before>using System;
using GraphQL;
using GraphQL.DataLoader;
using GraphQL.Execution;
using GraphQL.Http;
using GraphQL.Validation;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using OrchardCore.Admin;
using OrchardCore.Apis.GraphQL.Controllers;
using OrchardCore.Apis.GraphQL.Services;
using OrchardCore.Apis.GraphQL.ValidationRules;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
using OrchardCore.Mvc.Core.Utilities;
using OrchardCore.Navigation;
using OrchardCore.Security.Permissions;

namespace OrchardCore.Apis.GraphQL
{
    public class Startup : StartupBase
    {
        private readonly AdminOptions _adminOptions;
        private readonly IHostEnvironment _hostingEnvironment;

        public Startup(IOptions<AdminOptions> adminOptions, IHostEnvironment hostingEnvironment)
        {
            _adminOptions = adminOptions.Value;
            _hostingEnvironment = hostingEnvironment;
        }

        public override void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton<IDependencyResolver, RequestServicesDependencyResolver>();
            services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
            services.AddSingleton<IDocumentWriter, DocumentWriter>();
            services.AddSingleton<IDataLoaderContextAccessor, DataLoaderContextAccessor>();
            services.AddSingleton<IDocumentExecutionListener, DataLoaderDocumentListener>();
            services.AddSingleton<ISchemaFactory, SchemaService>();
            services.AddScoped<IValidationRule, MaxNumberOfResultsValidationRule>();
            services.AddScoped<IValidationRule, RequiresPermissionValidationRule>();

            services.AddScoped<IPermissionProvider, Permissions>();
            services.AddTransient<INavigationProvider, AdminMenu>();

            services.AddOptions<GraphQLSettings>().Configure<IShellConfiguration>((c, configuration) =>
            {
                var exposeExceptions = configuration.GetValue(
                    $"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.ExposeExceptions)}",
                    _hostingEnvironment.IsDevelopment());

                var maxNumberOfResultsValidationMode = configuration.GetValue<MaxNumberOfResultsValidationMode?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxNumberOfResultsValidationMode)}")
                                                        ?? MaxNumberOfResultsValidationMode.Default;

                if (maxNumberOfResultsValidationMode == MaxNumberOfResultsValidationMode.Default)
                {
                    maxNumberOfResultsValidationMode = _hostingEnvironment.IsDevelopment() ? MaxNumberOfResultsValidationMode.Enabled : MaxNumberOfResultsValidationMode.Disabled;
                }

                c.BuildUserContext = ctx => new GraphQLContext
                {
                    HttpContext = ctx,
                    User = ctx.User,
                    ServiceProvider = ctx.RequestServices
                };
                c.ExposeExceptions = exposeExceptions;
                c.MaxDepth = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxDepth)}") ?? 20;
                c.MaxComplexity = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxComplexity)}");
                c.FieldImpact = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.FieldImpact)}");
                c.MaxNumberOfResults = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxNumberOfResults)}") ?? 1000;
                c.MaxNumberOfResultsValidationMode = maxNumberOfResultsValidationMode;
                c.DefaultNumberOfResults = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.DefaultNumberOfResults)}") ?? 100;
            });
        }

        public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
        {
            routes.MapAreaControllerRoute(
                name: "GraphQL",
                areaName: "OrchardCore.Apis.GraphQL",
                pattern: _adminOptions.AdminUrlPrefix + "/GraphQL",
                defaults: new { controller = typeof(AdminController).ControllerName(), action = nameof(AdminController.Index) }
            );

            app.UseMiddleware<GraphQLMiddleware>(serviceProvider.GetService<IOptions<GraphQLSettings>>().Value);
        }
    }
}<commit_msg>GraphQL - field impact configuration should be a double not int (#5278)<commit_after>using System;
using GraphQL;
using GraphQL.DataLoader;
using GraphQL.Execution;
using GraphQL.Http;
using GraphQL.Validation;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using OrchardCore.Admin;
using OrchardCore.Apis.GraphQL.Controllers;
using OrchardCore.Apis.GraphQL.Services;
using OrchardCore.Apis.GraphQL.ValidationRules;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
using OrchardCore.Mvc.Core.Utilities;
using OrchardCore.Navigation;
using OrchardCore.Security.Permissions;

namespace OrchardCore.Apis.GraphQL
{
    public class Startup : StartupBase
    {
        private readonly AdminOptions _adminOptions;
        private readonly IHostEnvironment _hostingEnvironment;

        public Startup(IOptions<AdminOptions> adminOptions, IHostEnvironment hostingEnvironment)
        {
            _adminOptions = adminOptions.Value;
            _hostingEnvironment = hostingEnvironment;
        }

        public override void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton<IDependencyResolver, RequestServicesDependencyResolver>();
            services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
            services.AddSingleton<IDocumentWriter, DocumentWriter>();
            services.AddSingleton<IDataLoaderContextAccessor, DataLoaderContextAccessor>();
            services.AddSingleton<IDocumentExecutionListener, DataLoaderDocumentListener>();
            services.AddSingleton<ISchemaFactory, SchemaService>();
            services.AddScoped<IValidationRule, MaxNumberOfResultsValidationRule>();
            services.AddScoped<IValidationRule, RequiresPermissionValidationRule>();

            services.AddScoped<IPermissionProvider, Permissions>();
            services.AddTransient<INavigationProvider, AdminMenu>();

            services.AddOptions<GraphQLSettings>().Configure<IShellConfiguration>((c, configuration) =>
            {
                var exposeExceptions = configuration.GetValue(
                    $"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.ExposeExceptions)}",
                    _hostingEnvironment.IsDevelopment());

                var maxNumberOfResultsValidationMode = configuration.GetValue<MaxNumberOfResultsValidationMode?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxNumberOfResultsValidationMode)}")
                                                        ?? MaxNumberOfResultsValidationMode.Default;

                if (maxNumberOfResultsValidationMode == MaxNumberOfResultsValidationMode.Default)
                {
                    maxNumberOfResultsValidationMode = _hostingEnvironment.IsDevelopment() ? MaxNumberOfResultsValidationMode.Enabled : MaxNumberOfResultsValidationMode.Disabled;
                }

                c.BuildUserContext = ctx => new GraphQLContext
                {
                    HttpContext = ctx,
                    User = ctx.User,
                    ServiceProvider = ctx.RequestServices
                };
                c.ExposeExceptions = exposeExceptions;
                c.MaxDepth = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxDepth)}") ?? 20;
                c.MaxComplexity = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxComplexity)}");
                c.FieldImpact = configuration.GetValue<double?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.FieldImpact)}");
                c.MaxNumberOfResults = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.MaxNumberOfResults)}") ?? 1000;
                c.MaxNumberOfResultsValidationMode = maxNumberOfResultsValidationMode;
                c.DefaultNumberOfResults = configuration.GetValue<int?>($"OrchardCore.Apis.GraphQL:{nameof(GraphQLSettings.DefaultNumberOfResults)}") ?? 100;
            });
        }

        public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
        {
            routes.MapAreaControllerRoute(
                name: "GraphQL",
                areaName: "OrchardCore.Apis.GraphQL",
                pattern: _adminOptions.AdminUrlPrefix + "/GraphQL",
                defaults: new { controller = typeof(AdminController).ControllerName(), action = nameof(AdminController.Index) }
            );

            app.UseMiddleware<GraphQLMiddleware>(serviceProvider.GetService<IOptions<GraphQLSettings>>().Value);
        }
    }
}
{'fraction_non_alphanumeric': 0.08755419266152056, 'fraction_numerical': 0.0023263191286877444, 'mean_word_length': 3.209167779261237, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4228078', 'n_tokens_mistral': 2377, 'n_tokens_neox': 2263, 'n_words': 328}