-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (43 loc) · 1.16 KB
/
Program.cs
File metadata and controls
48 lines (43 loc) · 1.16 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
40
41
42
43
44
45
46
47
48
using Microsoft.EntityFrameworkCore;
using OrderGraphQlApi.Context;
using OrderGraphQlApi.GraphQl;
using OrderGraphQlApi.GraphQl.Inputs;
using OrderGraphQlApi.GraphQl.Types;
namespace OrderGraphQlApi
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPooledDbContextFactory<GraphQlDbContext>(options =>
{
options.UseNpgsql(builder.Configuration["ConnectionStrings:DbConnection"]);
});
builder.Services
.AddGraphQLServer()
.AddQueryType<Query>()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>()
.AddType<ProductType>()
.AddType<CustomerType>()
.AddType<OrderType>()
.AddType<OrderItemType>()
.AddType<InputObjectType<CustomerInputDto>>()
.AddType<InputObjectType<ProductInputDto>>()
.AddType<InputObjectType<OrderItemInputDto>>()
.RegisterDbContextFactory<GraphQlDbContext>()
.AddProjections()
.AddFiltering()
.AddSorting()
.AddInMemorySubscriptions();
var app = builder.Build();
app.MapGraphQL("/graphql");
app.Map("/orders", () =>
{
return "Ok";
});
app.Run();
}
}
}