WebApi + ClientApp, GraphQL, Reflection
This commit is contained in:
53
Events.GraphQL/Events.GraphQLServer/Program.cs
Normal file
53
Events.GraphQL/Events.GraphQLServer/Program.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user