Repository navigation
[Fusion] Write forwarded variable literals as UTF-8 - #10517
Merged
Merged
Conversation
Contributor
Patch coverage77.8% of changed lines covered (35/45)
Uncovered changed lines (JSON){
"sha": "7e7e55ef636f9b001713427c67693958eb5815bc",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/JsonVariableCoercion.cs", "ranges": [[477, 477], [479, 487]] }
]
}Project coverage: 58.6% (314214/536401 lines) |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
An unused import will fail CI, and forwarded UTF-8 serialization lacks direct regression coverage.
2 open findings
What changed in this PR
Updates Fusion to preserve forwarded variable literals as UTF-8 through coercion and serialization.
Changes:
- Stores coerced strings and enums as UTF-8.
- Writes value-node spans directly to JSON.
- Adds escape-sequence coercion tests.
| File | Description |
|---|---|
VariableCoercionHelperTests.cs |
Tests escaped strings and enums. |
FetchResultStore.cs |
Serializes value nodes directly from UTF-8 spans. |
JsonVariableCoercion.cs |
Coerces JSON strings and enums into UTF-8-backed nodes. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 25, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The gateway forwarded string and enum variables to source schemas through UTF-16 strings: variable coercion called
JsonElement.GetString()for every value, andFetchResultStoretranscoded those strings back to UTF-8 when writing the source schema request.This PR keeps forwarded variables in UTF-8.
JsonVariableCoercioncopies the raw UTF-8 bytes of string and enum values into the request'sUtf8MemoryBuilder(unescaping them when the JSON string contains escape sequences) and creates segment-backedStringValueNodeandEnumValueNodeliterals.FetchResultStorewrites string, enum, int and float literals from their UTF-8 spans, so no strings are created for forwarded variables.Benchmarks
Enums (21 enum values)
mainmain256 character strings (21 values)
mainmain16 KB lorem ipsum string (1 value)
mainmainGateway requests allocate 2% less with enum variables, 14% less with 256 character strings and 26% less with a 16 KB string, because each forwarded string value is no longer held as a UTF-16 string. With the 16 KB string, the gateway request is also 6% faster. The other time differences are within the measurement error (about ±0.2 to ±0.5 μs for gateway requests).