Repository navigation
Add MaxBatchSize support on source-generated DataLoader - #10023
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements issue #9897 by adding MaxBatchSize support to source-generated DataLoaders, flowing the value from [DataLoader(MaxBatchSize = ...)] through the analyzer model into generated DataLoader constructors (via DataLoaderOptions).
Changes:
- Add
MaxBatchSizetoDataLoaderAttributeand extract it in the analyzer (DataLoaderInfo/DataLoaderAttributeHelper). - Update the source generator to emit an options wrapper (
CreateOptions) that appliesMaxBatchSizewhen specified. - Add analyzer snapshot tests and an integration test verifying runtime batching splits keys according to
MaxBatchSize.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Core/test/Types.Analyzers.Tests/DataLoaderTests.cs | Adds snapshot-based analyzer tests for MaxBatchSize codegen. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/DataLoaderTests.GenerateSource_BatchDataLoader_With_MaxBatchSize_MatchesSnapshot.md | Snapshot verifying generated batch DataLoader applies MaxBatchSize via options. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/DataLoaderTests.GenerateSource_CacheDataLoader_With_MaxBatchSize_MatchesSnapshot.md | Snapshot verifying generated cache DataLoader applies MaxBatchSize via options. |
| src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/DataLoaderTests.cs | Integration test asserting dispatched batch sizes match MaxBatchSize splitting behavior. |
| src/HotChocolate/Core/src/Types.Analyzers/Models/DataLoaderInfo.cs | Adds MaxBatchSize to the analyzer model. |
| src/HotChocolate/Core/src/Types.Analyzers/Helpers/DataLoaderAttributeHelper.cs | Extracts MaxBatchSize from attribute named arguments. |
| src/HotChocolate/Core/src/Types.Analyzers/Generators/DataLoaderGenerator.cs | Passes MaxBatchSize into the file builder when generating constructors. |
| src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/DataLoaderFileBuilder.cs | Generates CreateOptions(options) and sets local.MaxBatchSize when specified. |
| src/GreenDonut/src/GreenDonut.Abstractions/Attributes/DataLoaderAttribute.cs | Adds MaxBatchSize to the public attribute API (docs + property). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+31
to
+36
| /// <summary> | ||
| /// Gets or sets the maximum number of keys that are dispatched to the fetch method in a | ||
| /// single batch. When not set, the DataLoader uses the default batch size. A value of | ||
| /// <c>0</c> disables batch splitting so that all buffered keys are dispatched together. | ||
| /// </summary> | ||
| public int MaxBatchSize { get; set; } |
Contributor
Patch coverage97.0% of changed lines covered (32/33)
Uncovered changed lines (JSON){
"sha": "931fe6402feb0fea7308299e7401dcbcd67fa82e",
"files": [
{ "path": "src/GreenDonut/src/GreenDonut.Abstractions/Attributes/DataLoaderAttribute.cs", "ranges": [[36, 36]] }
]
}Project coverage: 52.5% (217057/413246 lines) |
This was referenced Jul 7, 2026
This was referenced Jul 14, 2026
This was referenced Jul 23, 2026
This was referenced Sep 1, 2026
Closed
This was referenced Sep 15, 2026
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#405
Closed
This was referenced Sep 22, 2026
Closed
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#410
Merged
This was referenced Oct 5, 2026
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.
Implements #9897