Improve selection lookup on value completion#9997
Draft
michaelstaib wants to merge 2 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves performance of value completion by avoiding repeated “selection-set discovery” work when mapping source JSON object properties onto a composite result object that was created from a known SelectionSet.
Changes:
- Added
TryGetObjectScopeto pre-bind aSelectionSet+ object start cursor and perform fast property-to-cursor mapping during completion. - Updated
ValueCompletionto use the object scope for property lookup when available, falling back to the existing name-based lookup otherwise. - Added a regression test ensuring
TryGetObjectScopecorrectly returnsfalse(and lookup still works) when an object has no selection-set metadata.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Text/Json/CompositeResultDocumentTests.cs | Adds a test covering the “no selection set metadata” fallback path for TryGetObjectScope. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultElement.cs | Exposes an internal TryGetObjectScope helper on CompositeResultElement. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/CompositeResultDocument.TryGetProperty.cs | Implements TryGetObjectScope and introduces CompositeResultObjectScope for fast selection-based property access. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs | Uses CompositeResultObjectScope to speed up repeated property lookups during object completion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Patch coverage75.2% of changed lines covered (1568/2084) +76 more changed files; see the JSON below for uncovered lines. Uncovered changed lines (JSON){
"sha": "70b2ab16d8c754f3285e139ae2deeec6153af91a",
"files": [
{ "path": "src/HotChocolate/Core/src/Types/Execution/Options/NodeIdSerializerOptions.cs", "ranges": [[56, 56]] },
{ "path": "src/HotChocolate/Core/src/Types/Types/Descriptors/UnionTypeDescriptor.cs", "ranges": [[95, 95]] },
{ "path": "src/Mocha/src/Mocha.Abstractions/MessagingModuleAttribute.cs", "ranges": [[31, 31]] },
{ "path": "src/Mocha/src/Mocha.Abstractions/MessagingModuleInfoAttribute.cs", "ranges": [[14, 14], [19, 19], [24, 24]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/ImportedMediatorModuleTypesInfo.cs", "ranges": [[17, 20], [23, 23]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/ImportedModuleTypesInfo.cs", "ranges": [[20, 24], [27, 27]] },
{ "path": "src/Mocha/src/Mocha.Mediator.Abstractions/MediatorModuleInfoAttribute.cs", "ranges": [[14, 14], [19, 19]] },
{ "path": "src/Mocha/src/Mocha.Transport.Postgres/Tasks/QueueMonitoringTask.cs", "ranges": [[26, 34]] },
{ "path": "src/Mocha/src/Mocha/Configuration/MessagingSagaConfiguration.cs", "ranges": [[15, 15], [20, 20]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Inspectors/ImportedModuleTypeInspector.cs", "ranges": [[47, 48], [50, 52], [55, 55], [57, 60], [64, 68], [71, 73], [75, 79], [82, 88], [90, 92], [95, 102], [104, 111], [113, 113], [115, 116]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Inspectors/ImportedMediatorModuleTypeInspector.cs", "ranges": [[48, 49], [51, 53], [56, 56], [58, 61], [65, 69], [72, 73], [75, 79], [82, 87], [89, 91], [94, 101], [103, 109], [111, 111], [113, 114]] },
{ "path": "src/HotChocolate/Core/src/Types/Execution/Requirements/RequirementsTypeInterceptor.cs", "ranges": [[49, 50]] },
{ "path": "src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker.Enter.cs", "ranges": [[282, 282], [287, 287]] },
{ "path": "src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker.Leave.cs", "ranges": [[283, 283], [288, 288]] },
{ "path": "src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker~1.Enter.cs", "ranges": [[284, 284], [289, 289]] },
{ "path": "src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker~1.Leave.cs", "ranges": [[283, 283], [288, 288]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/KnownTypeSymbols.cs", "ranges": [[149, 149], [155, 155]] },
{ "path": "src/Mocha/src/Mocha/Extensions/IMessageBusHostBuilderExtensions.cs", "ranges": [[86, 89], [103, 106]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/JsonSegment.cs", "ranges": [[80, 80], [94, 94], [99, 100], [107, 109]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Inspectors/CallSiteMessageTypeInspector.cs", "ranges": [[47, 48], [55, 56], [61, 62], [73, 76], [80, 83], [86, 86], [110, 111], [113, 114], [119, 119], [125, 134], [137, 137], [142, 143], [176, 176], [180, 181], [196, 197], [199, 199], [202, 202], [205, 206], [208, 209], [211, 211], [218, 220], [223, 226], [229, 232], [235, 239], [245, 246], [248, 250], [254, 256], [259, 262], [265, 269], [277, 278]] },
{ "path": "src/Mocha/src/Mocha/Serialization/MessageTypeRegistry.cs", "ranges": [[63, 67]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/MediatorGenerator.cs", "ranges": [[122, 122], [163, 166], [169, 169], [171, 175], [177, 177], [179, 180], [280, 288], [312, 313], [347, 347], [349, 355], [358, 367], [370, 386]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/AotPublishInfo.cs", "ranges": [[12, 12]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/SagaInfo.cs", "ranges": [[11, 11]] },
{ "path": "src/Mocha/src/Mocha/Builder/MessageBusBuilder.cs", "ranges": [[89, 89], [171, 177], [225, 231], [254, 255], [257, 257], [259, 265], [459, 461]] },
{ "path": "src/HotChocolate/Core/src/Types/Internal/TypeExtensionHelper.cs", "ranges": [[29, 31]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/ContextOnlyMessageInfo.cs", "ranges": [[21, 21], [24, 24]] },
{ "path": "src/Mocha/src/Mocha/Sagas/State/Serialization/JsonSagaStateSerializerFactory.cs", "ranges": [[38, 42]] },
{ "path": "src/Mocha/src/Mocha/Serialization/JsonMessageSerializerFactory.cs", "ranges": [[40, 44]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/JsonContextSerializableTypesInfo.cs", "ranges": [[19, 19]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Inspectors/MessagingHandlerInspector.cs", "ranges": [[99, 102]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/ArenaBufferWriter.cs", "ranges": [[60, 60], [113, 113], [123, 123], [128, 128], [131, 131], [135, 135], [193, 194], [209, 209], [218, 223], [225, 228], [231, 233], [235, 239], [241, 246], [248, 249], [294, 296]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/MessagingGenerator.cs", "ranges": [[193, 194], [205, 205], [207, 207], [262, 264], [315, 318], [328, 329], [336, 337], [342, 343], [347, 348], [403, 406], [497, 502], [512, 515], [517, 526], [532, 533], [564, 566], [569, 571], [602, 604], [632, 637], [705, 707], [717, 719]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Models/CallSiteMessageTypeInfo.cs", "ranges": [[23, 23]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs", "ranges": [[806, 807], [1395, 1395], [1397, 1397], [1430, 1430], [1790, 1791], [1805, 1807], [1809, 1812], [1814, 1816], [1836, 1838], [1864, 1866]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs", "ranges": [[93, 93], [837, 837]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Generators/MessagingDependencyInjectionGenerator.cs", "ranges": [[37, 37], [74, 78], [80, 83], [85, 89], [117, 119], [132, 132], [139, 139], [200, 201]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Filters/InvocationCallSiteFilter.cs", "ranges": [[28, 28], [30, 30]] },
{ "path": "src/HotChocolate/Core/src/Execution.Projections/SelectionExpressionBuilder.cs", "ranges": [[322, 322]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.Pooling.cs", "ranges": [[193, 193]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/FileBuilders/MessagingDependencyInjectionFileBuilder.cs", "ranges": [[214, 219]] },
{ "path": "src/Mocha/src/Mocha.Analyzers/Inspectors/HandlerInspector.cs", "ranges": [[131, 131]] }
]
}Project coverage: 52.5% (216595/412700 lines) |
michaelstaib
marked this pull request as draft
June 29, 2026 19:08
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.
No description provided.