Skip to content

Add Fusion Transport Layer - #8410

Merged
michaelstaib merged 12 commits into
mainfrom
mst/transport-abstractions
Jul 6, 2025
Merged

michaelstaib merged 12 commits into
mainfrom
mst/transport-abstractions

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Jul 1, 2025 •

Copy link
Copy Markdown
Member
  • Creates new transport abstractions
  • Bases Hot Chocolate transport on new transport abstractions
  • Introduces Fusion transport

Comment thread src/All.slnx Outdated
Comment thread src/HotChocolate/AspNetCore/HotChocolate.AspNetCore.slnx Outdated
@michaelstaib michaelstaib self-assigned this Jul 2, 2025
@michaelstaib
michaelstaib requested a review from Copilot July 6, 2025 15:08

This comment was marked as outdated.

@michaelstaib
michaelstaib requested a review from Copilot July 6, 2025 21:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds foundational transport abstractions and integrates them into existing HTTP and WebSocket transports, while replacing legacy buffer helpers with a unified pooled writer approach across the codebase. Key changes include:

  • Refactored low-level buffering: removed BufferHelper, updated PooledArrayWriter to implement IMemoryOwner<byte> with WrittenMemory/WrittenSpan, and introduced PooledArrayWriterMarshal and JsonDocumentOwner.
  • Switched all direct calls from GetWrittenMemory/GetWrittenSpan to the new properties, and updated JSON parsing/formatting accordingly.
  • Consolidated context data keys by replacing many usages of WellKnownContextData with ExecutionContextData.

Reviewed Changes

Copilot reviewed 175 out of 234 changed files in this pull request and generated 3 comments.

File Description
src/HotChocolate/Utilities/src/Utilities/BufferHelper.cs Removed; streaming logic now uses PooledArrayWriter directly.
src/HotChocolate/Utilities/src/Utilities.Buffers/PooledArrayWriter.cs Changed to implement IMemoryOwner<byte>, added WrittenMemory/WrittenSpan, and removed legacy methods.
src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/FusionRequestExecutorManager.cs Added channel-based observer pattern for executor creation/eviction and a file-scoped extensions helper.
src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/Extensions/ServiceCollectionExtensions.cs Introduced a custom AddHttpClient extension to wire TestServer into IHttpClientFactory for tests.
Files not reviewed (1)
  • src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/Pipeline/OperationVariableCoercionMiddleware.cs:44

  • Changing TryCoerceVariables from public to private restricts its accessibility and may break callers who rely on it; consider preserving its public API surface or updating all references.
    private static bool TryCoerceVariables(

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/FusionRequestExecutorManager.cs:589

  • [nitpick] The class name Extensions is very generic and could clash with other extension-method classes; consider renaming it to something more descriptive.
file static class Extensions

Comment on lines +49 to +59
const int chunkSize = 256;
await using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
using var writer = new PooledArrayWriter();
var read = 0;

var document = await BufferHelper.ReadAsync(
stream,
static (buffer, buffered) =>
{
var span = buffer.AsSpan()[..buffered];
return Utf8GraphQLParser.Parse(span);
},
cancellationToken)
.ConfigureAwait(false);
do
{
var memory = writer.GetMemory(chunkSize);
read = await stream.ReadAsync(memory, cancellationToken).ConfigureAwait(false);
writer.Advance(read);
} while (read == chunkSize);

Copilot AI Jul 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a fixed chunk size of 256 bytes may cause many small reads for larger files; consider increasing or making this buffer size configurable to reduce IO overhead.

Copilot uses AI. Check for mistakes.
@michaelstaib
michaelstaib merged commit a0866ea into main Jul 6, 2025
@michaelstaib
michaelstaib deleted the mst/transport-abstractions branch July 6, 2025 21:37
JesseXia pushed a commit to JesseXia/graphql-platform that referenced this pull request Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants