Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/AspNetCore/AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Expand All @@ -17,7 +17,6 @@

<ItemGroup>
<PackageReference Include="GraphQL" Version="2.0.0-alpha-864" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
Expand Down
21 changes: 6 additions & 15 deletions src/AspNetCore/GraphQLExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using GraphQL.Http;
using GraphQL.Subscription;
using GraphQL.Types;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace GraphQL.Server.Transports.AspNetCore
{
Expand All @@ -14,19 +13,11 @@ public static class GraphQLExtensions
/// <summary>
/// Adds the GraphQLHttp to services
/// </summary>
/// <param name="services">The service collection to register the services on</param>
/// <returns>The <see cref="IServiceCollection"/> received as parameter</returns>
/// <param name="services">The servicecollection to registrer the services on</param>
/// <returns>The <see cref="IServiceCollection"/> recieved as parameter</returns>
public static IServiceCollection AddGraphQLHttp(this IServiceCollection services)
{
services.TryAddSingleton<IDocumentWriter>(
x =>
{
var hostingEnvironment = x.GetRequiredService<IHostingEnvironment>();
var jsonSerializerSettings = x.GetRequiredService<IOptions<JsonSerializerSettings>>();
return new DocumentWriter(
hostingEnvironment.IsDevelopment() ? Formatting.Indented : Formatting.None,
jsonSerializerSettings.Value);
});
services.TryAddSingleton<IDocumentWriter, DocumentWriter>();
services.TryAddSingleton<IDocumentExecuter, DocumentExecuter>();

return services;
Expand All @@ -36,8 +27,8 @@ public static IServiceCollection AddGraphQLHttp(this IServiceCollection services
/// Adds the GraphQLHttp to services
/// </summary>
/// <typeparam name="TUserContextBuilder">The <see cref="IUserContextBuilder"/> to use for generating the userContext used for the GraphQL request</typeparam>
/// <param name="services">The service collection to register the services on</param>
/// <returns>The <see cref="IServiceCollection"/> received as parameter</returns>
/// <param name="services">The servicecollection to registrer the services on</param>
/// <returns>The <see cref="IServiceCollection"/> recieved as parameter</returns>
public static IServiceCollection AddGraphQLHttp<TUserContextBuilder>(this IServiceCollection services)
where TUserContextBuilder : class, IUserContextBuilder
{
Expand Down