54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using Events.EF.Data.Postgres;
|
|
using GraphQL.Server.Ui.Voyager;
|
|
using GraphQLServer.SetupGraphQL;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
#region Configure services
|
|
|
|
builder.Services.AddDbContext<EventsContext>(options =>
|
|
options.UseNpgsql(builder.Configuration.GetConnectionString("EventsPostgres")));
|
|
|
|
builder.Services.AddGraphQLServer()
|
|
.ModifyRequestOptions(opt => opt.IncludeExceptionDetails = builder.Environment.IsDevelopment())
|
|
.ModifyPagingOptions(options =>
|
|
{
|
|
options.DefaultPageSize = 20;
|
|
options.MaxPageSize = 1000;
|
|
options.IncludeTotalCount = true;
|
|
})
|
|
.AddProjections()
|
|
.AddFiltering()
|
|
.AddSorting()
|
|
.AddQueryType<Queries>()
|
|
.AddMutationType<Mutations>();
|
|
#endregion
|
|
|
|
var app = builder.Build();
|
|
|
|
#region Configure middleware pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.MapGraphQL();
|
|
|
|
app.UseGraphQLVoyager("/voyager", new VoyagerOptions() { GraphQLEndPoint = "graphql" });
|
|
app.UseGraphQLGraphiQL(
|
|
"/",
|
|
new GraphQL.Server.Ui.GraphiQL.GraphiQLOptions
|
|
{
|
|
GraphQLEndPoint = "/graphql",
|
|
SubscriptionsEndPoint = "/graphql",
|
|
});
|
|
#endregion
|
|
|
|
app.Run();
|