-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (36 loc) · 1.14 KB
/
Program.cs
File metadata and controls
39 lines (36 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using CommanderGQL.Data;
using CommanderGQL.GraphQL;
using GraphQL.Server.Ui.Voyager;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Builder;
using CommanderGQL.GraphQL.Commands;
using Microsoft.EntityFrameworkCore;
using CommanderGQL.GraphQL.Platforms;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPooledDbContextFactory<AppDbContext>(opt =>
opt.UseSqlServer(builder.Configuration.GetConnectionString("CommandConStr")));
builder.Services
.AddGraphQLServer()
.AddQueryType<Query>()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>()
.ModifyRequestOptions(opt => opt.IncludeExceptionDetails = builder.Environment.IsDevelopment())
.AddType<PlatformType>()
.AddType<CommandType>()
.AddFiltering()
.AddSorting()
.AddInMemorySubscriptions();
var app = builder.Build();
app.UseWebSockets();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGraphQL();
});
app.UseGraphQLVoyager("/graphql-voyager", new VoyagerOptions()
{
GraphQLEndPoint = "/graphql"
});
app.Run();