コード例 #1
0
    public void ConfigureServices(IServiceCollection services)
    {
        GraphTypeTypeRegistry.Register <Employee, EmployeeGraph>();
        GraphTypeTypeRegistry.Register <EmployeeSummary, EmployeeSummaryGraph>();
        GraphTypeTypeRegistry.Register <Company, CompanyGraph>();
        services.AddScoped(_ => DbContextBuilder.BuildDbContext());
        EfGraphQLConventions.RegisterInContainer <GraphQlEfSampleDbContext>(
            services,
            model: GraphQlEfSampleDbContext.StaticModel);
        EfGraphQLConventions.RegisterConnectionTypesInContainer(services);

        foreach (var type in GetGraphQlTypes())
        {
            services.AddSingleton(type);
        }

        var graphQl = services.AddGraphQL(
            options => options.ExposeExceptions = true);

        graphQl.AddWebSockets();
        services.AddSingleton <ContextFactory>();
        services.AddSingleton <IDocumentExecuter, EfDocumentExecuter>();
        services.AddSingleton <IDependencyResolver>(
            provider => new FuncDependencyResolver(provider.GetRequiredService));
        services.AddSingleton <ISchema, Schema>();
        var mvc = services.AddMvc(option => option.EnableEndpointRouting = false);

        mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
        mvc.AddNewtonsoftJson();
    }
コード例 #2
0
    public void ConfigureServices(IServiceCollection services)
    {
        GraphTypeTypeRegistry.Register <Employee, EmployeeGraph>();
        GraphTypeTypeRegistry.Register <EmployeeSummary, EmployeeSummaryGraph>();
        GraphTypeTypeRegistry.Register <Company, CompanyGraph>();
        EfGraphQLConventions.RegisterInContainer <SampleDbContext>(
            services,
            model: SampleDbContext.StaticModel);
        EfGraphQLConventions.RegisterConnectionTypesInContainer(services);

        foreach (var type in GetGraphQlTypes())
        {
            services.AddSingleton(type);
        }
        //TODO: re add for subscriptions
        //var graphQl = services.AddGraphQL(
        //    options => options.ExposeExceptions = true);
        //graphQl.AddWebSockets();

        var dbContextBuilder = new DbContextBuilder();

        services.AddSingleton <IHostedService>(dbContextBuilder);
        services.AddSingleton <Func <SampleDbContext> >(_ => dbContextBuilder.BuildDbContext);
        services.AddScoped(_ => dbContextBuilder.BuildDbContext());
        services.AddSingleton <IDocumentExecuter, EfDocumentExecuter>();
        services.AddSingleton <ISchema, Schema>();
        var mvc = services.AddMvc(option => option.EnableEndpointRouting = false);

        mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
        mvc.AddNewtonsoftJson();
    }
コード例 #3
0
    public void ConfigureServices(IServiceCollection services)
    {
        GraphTypeTypeRegistry.Register <Employee, EmployeeGraph>();
        GraphTypeTypeRegistry.Register <EmployeeSummary, EmployeeSummaryGraph>();
        GraphTypeTypeRegistry.Register <Company, CompanyGraph>();

        services.AddScoped(provider => DbContextBuilder.BuildDbContext());

        EfGraphQLConventions.RegisterInContainer(
            services,
            DbContextBuilder.BuildDbContext(),
            userContext => (GraphQlEfSampleDbContext)userContext);

        foreach (var type in GetGraphQlTypes())
        {
            services.AddSingleton(type);
        }

        services.AddGraphQL(options => options.ExposeExceptions = true).AddWebSockets();
        services.AddSingleton <ContextFactory>();
        services.AddSingleton <IDocumentExecuter, EfDocumentExecuter>();
        services.AddSingleton <IDependencyResolver>(
            provider => new FuncDependencyResolver(provider.GetRequiredService));
        services.AddSingleton <ISchema, Schema>();
        var mvc = services.AddMvc();

        mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
    }
コード例 #4
0
        public void SetUp()
        {
            var builder = new DbContextBuilder<DbContext>("DefaultDb", new[] { "Infrastructure.Tests" }, true, true);
            this.context = builder.BuildDbContext();

            this.customerRepository = new CustomerRepository(this.context);
            this.repository = new GenericRepository(this.context);
        }
コード例 #5
0
        public void SetUp()
        {
            DbContextBuilder<DbContext> builder = new DbContextBuilder<DbContext>("DefaultDb", new[] { "QV.Tests" }, true, true);
            context = builder.BuildDbContext();

            customerRepository = new QV.Tests.Data.Lab.CustomerRepository(context);
            repository = new QV.Data.EntityFramework.Lab.GenericRepository(context);
        }
コード例 #6
0
        public void SetUp()
        {
            DbContextBuilder <DbContext> builder = new DbContextBuilder <DbContext>("DefaultDb", new[] { "Infrastructure.Tests" }, true, true);

            context = builder.BuildDbContext();

            customerRepository = new Infrastructure.Tests.Data.Lab.CustomerRepository(context);
            repository         = new Infrastructure.Data.EntityFramework.Lab.GenericRepository(context);
        }
コード例 #7
0
        public void SetUp()
        {
            DbContextBuilder <DbContext> builder = new DbContextBuilder <DbContext>("DefaultDb", new[] { "Infrastructure.Tests" }, true, true);

            context = builder.BuildDbContext();

            customerRepository = new CustomerRepository(context);
            repository         = new GenericRepository(context);
        }
コード例 #8
0
 public GraphQlEfSampleDbContext BuildContext() => DbContextBuilder.BuildDbContext();