Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Sep 2, 2022
2 parents 4f52583 + d80414d commit 04a3317
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ This is because `Newtonsoft.Json` is the default serializer for ASP.NET Core 2.1
rather `System.Text.Json`. When using `GraphQL.NewtonsoftJson`, you will need to call
`AddNewtonsoftJson()` rather than `AddSystemTextJson()` while configuring GraphQL.NET.

<details><summary>Microsoft support policy</summary><p>

Please note that .NET Core 2.1 is currently out of support by Microsoft.
.NET Framework 4.8 is supported, and ASP.NET Core 2.1 is supported when run on
.NET Framework 4.8. Please see these links for more information:

- https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-framework
- https://dotnet.microsoft.com/en-us/platform/support/policy/aspnetcore-2.1
</p></details>

## Advanced configuration

For more advanced configurations, see the overloads and configuration options
Expand Down
2 changes: 1 addition & 1 deletion Tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
Expand Down
2 changes: 1 addition & 1 deletion src/Transports.AspNetCore/GraphQLHttpMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ protected virtual string SelectResponseContentType(HttpContext context)
}
}

return CONTENTTYPE_GRAPHQLRESPONSEJSON;
return _options.ResponseContentType;
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Transports.AspNetCore/GraphQLHttpMiddlewareOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public class GraphQLHttpMiddlewareOptions : IAuthorizationOptions
/// Returns an options class for WebSocket connections.
/// </summary>
public GraphQLWebSocketOptions WebSockets { get; set; } = new();

/// <summary>
/// The Content-Type to use for GraphQL responses
/// </summary>
public string ResponseContentType { get; set; } = GraphQLHttpMiddleware.CONTENTTYPE_GRAPHQLRESPONSEJSON;
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace GraphQL.Server.Transports.AspNetCore
public bool ReadExtensionsFromQueryString { get; set; }
public bool ReadQueryStringOnPost { get; set; }
public bool ReadVariablesFromQueryString { get; set; }
public string ResponseContentType { get; set; }
public bool ValidationErrorsReturnBadRequest { get; set; }
public GraphQL.Server.Transports.AspNetCore.WebSockets.GraphQLWebSocketOptions WebSockets { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ namespace GraphQL.Server.Transports.AspNetCore
public bool ReadExtensionsFromQueryString { get; set; }
public bool ReadQueryStringOnPost { get; set; }
public bool ReadVariablesFromQueryString { get; set; }
public string ResponseContentType { get; set; }
public bool ValidationErrorsReturnBadRequest { get; set; }
public GraphQL.Server.Transports.AspNetCore.WebSockets.GraphQLWebSocketOptions WebSockets { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Transports.AspNetCore.Tests/TestServerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static async Task<string> ExecutePost(this TestServer server, string url,
{
var client = server.CreateClient();
var data = System.Text.Json.JsonSerializer.Serialize(new { query = query, variables = variables });
var content = new StringContent(data, Encoding.UTF8, "application/json");
using var content = new StringContent(data, Encoding.UTF8, "application/json");
using var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
var str = await response.Content.ReadAsStringAsync();
Expand Down

0 comments on commit 04a3317

Please sign in to comment.