Skip to content

Commit bd70872

Browse files
authored
Reworked Transport Formatters and Parsers (#8491)
1 parent e3870cb commit bd70872

24 files changed

+1076
-769
lines changed

src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Formatters/DefaultHttpResponseFormatter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected virtual RequestFlags CreateRequestFlags(
157157
flags |= RequestFlags.AllowStreams;
158158
}
159159

160-
if (acceptMediaType.Kind is EventStream or All)
160+
if (acceptMediaType.Kind is ApplicationGraphQLStream or EventStream or ApplicationJsonLines or All)
161161
{
162162
flags = RequestFlags.AllowAll;
163163
}
@@ -443,7 +443,10 @@ protected virtual HttpStatusCode OnDetermineStatusCode(
443443
// if we are sending a response stream with the multipart/mixed header or
444444
// with a text/event-stream response content-type, we as well will just
445445
// respond with an OK status code.
446-
if (format.Kind is ResponseContentType.MultiPartMixed or ResponseContentType.EventStream)
446+
if (format.Kind is ResponseContentType.MultiPartMixed
447+
or ResponseContentType.EventStream
448+
or ResponseContentType.GraphQLResponseStream
449+
or ResponseContentType.JsonLines)
447450
{
448451
return HttpStatusCode.OK;
449452
}

src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/HttpPostMiddlewareBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected async Task HandleRequestAsync(HttpContext context, ExecutorSession ses
5656
// with a 400 Bad Request.
5757
if (headerResult.HasError)
5858
{
59-
// in this case accept headers were specified and we will
59+
// in this case accept headers were specified, and we will
6060
// respond with proper error codes
6161
acceptMediaTypes = HeaderUtilities.GraphQLResponseContentTypes;
6262
statusCode = HttpStatusCode.BadRequest;
@@ -73,7 +73,7 @@ protected async Task HandleRequestAsync(HttpContext context, ExecutorSession ses
7373
// media type then we will fail the request with 406 Not Acceptable.
7474
if (requestFlags is None)
7575
{
76-
// in this case accept headers were specified and we will
76+
// in this case accept headers were specified, and we will
7777
// respond with proper error codes
7878
acceptMediaTypes = HeaderUtilities.GraphQLResponseContentTypes;
7979
statusCode = HttpStatusCode.NotAcceptable;

src/HotChocolate/AspNetCore/src/Transport.Abstractions/ContentType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public static class ContentType
1919
/// Gets the text/event-stream content type.
2020
/// </summary>
2121
public const string EventStream = "text/event-stream";
22+
23+
/// <summary>
24+
/// Gets the application/graphql-response+jsonl content type.
25+
/// </summary>
26+
public const string GraphQLJsonLine = "application/graphql-response+jsonl";
2227
}

src/HotChocolate/AspNetCore/src/Transport.Formatters/ConcurrentStreamWriter.cs

Lines changed: 0 additions & 164 deletions
This file was deleted.

0 commit comments

Comments
 (0)