Permalink
Switch branches/tags
Nothing to show
Find file Copy path
61203a6 Mar 15, 2018
1 contributor

Users who have contributed to this file

58 lines (50 sloc) 2 KB
using GraphQL;
using GraphQL.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NHLStats.Api.Models;
using NHLStats.Core.Data;
using NHLStats.Data;
using NHLStats.Data.Repositories;
namespace NHLStats.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDbContext<NHLStatsContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:NHLStatsDb"]));
services.AddTransient<IPlayerRepository, PlayerRepository>();
services.AddTransient<ISkaterStatisticRepository, SkaterStatisticRepository>();
services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
services.AddSingleton<NHLStatsQuery>();
services.AddSingleton<NHLStatsMutation>();
services.AddSingleton<PlayerType>();
services.AddSingleton<PlayerInputType>();
services.AddSingleton<SkaterStatisticType>();
var sp = services.BuildServiceProvider();
services.AddSingleton<ISchema>(new NHLStatsSchema(new FuncDependencyResolver(type => sp.GetService(type))));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, NHLStatsContext db)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseGraphiQl();
app.UseMvc();
db.EnsureSeedData();
}
}
}