2020-02-15 16:00:42 +03:00
|
|
|
using HotChocolate;
|
|
|
|
|
using HotChocolate.AspNetCore;
|
|
|
|
|
using HotChocolate.AspNetCore.Voyager;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-02-23 23:27:12 +03:00
|
|
|
using WotBlitzStatistics.GraphQl.ObjectTypes;
|
2020-02-15 16:00:42 +03:00
|
|
|
using WotBlitzStatistics.GraphQl.Query;
|
|
|
|
|
using WotBlitzStatisticsPro.WgApiClient;
|
2020-02-23 23:27:12 +03:00
|
|
|
using WotBlitzStatisticsPro.WgApiClient.Model;
|
2020-02-15 16:00:42 +03:00
|
|
|
|
|
|
|
|
namespace WotBlitzStatistics.GraphQl
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
Configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
var wgApiConfig = new WargamingApiSettings();
|
|
|
|
|
Configuration.GetSection("WargamingApi").Bind(wgApiConfig);
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IWargamingApiSettings>(wgApiConfig);
|
|
|
|
|
services.AddHttpClient<IWargamingApiClient, WargamingApiClient>();
|
|
|
|
|
|
|
|
|
|
// Add GraphQL Services
|
|
|
|
|
services.AddGraphQL(sp => SchemaBuilder.New()
|
|
|
|
|
.AddServices(sp)
|
|
|
|
|
|
|
|
|
|
// Adds the authorize directive and
|
|
|
|
|
// enable the authorization middleware.
|
|
|
|
|
.AddAuthorizeDirectiveType()
|
|
|
|
|
|
2020-02-18 17:01:12 +01:00
|
|
|
.AddQueryType<WotBlitzStatisticsQuery>()
|
2020-02-15 16:00:42 +03:00
|
|
|
//.AddMutationType<MutationType>()
|
|
|
|
|
//.AddSubscriptionType<SubscriptionType>()
|
2020-02-23 23:27:12 +03:00
|
|
|
.AddType<PlayerAccountInfoObjectType>()
|
|
|
|
|
.AddType<AccountStatistics>()
|
|
|
|
|
.AddType<AccountFullStatistics>()
|
2020-02-25 00:46:02 +03:00
|
|
|
.AddType<PlayerClanInfoObjectType>()
|
2020-02-23 23:27:12 +03:00
|
|
|
//.AddEnumType<MarkOfMastery>()
|
2020-02-15 16:00:42 +03:00
|
|
|
.Create());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
app
|
|
|
|
|
.UseGraphQL("/graphql")
|
|
|
|
|
.UsePlayground("/graphql")
|
|
|
|
|
.UseVoyager("/graphql")
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|