-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartup.cs
42 lines (38 loc) · 1.41 KB
/
Startup.cs
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
using System;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Owin;
using Owin;
using GraphQL.Server;
using GraphQL.Server.Ui.Playground;
using GraphQL;
[assembly: OwinStartup(typeof(FrameworkConsoleApp.Startup))]
namespace FrameworkConsoleApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_2)
.AddWebApiConventions();
services.AddScoped<PlayerRepository>();
services.AddScoped<PlayerSchema>();
services.AddScoped<IDependencyResolver>(s => new FuncDependencyResolver(s.GetRequiredService));
services.AddGraphQL().AddGraphTypes(ServiceLifetime.Scoped);
services.AddCors();
}
public void Configure(IApplicationBuilder app)
{
app.UseCors(builder =>
builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
app.UseGraphQL<PlayerSchema>();
//app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
/*
app.UseMvc(routes => routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }));
*/
}
}
}