Repository navigation
Allow Dictionary<TKey, T> as DataLoader return type - #10370
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, consistently applied across analyzer/model/docs, and covered by updated tests and snapshots for both valid and invalid cases.
Pull request overview
This PR expands the [DataLoader<T>] analyzer/source-generator contract validation to allow Dictionary<TKey, TValue> (in addition to IReadOnlyDictionary<TKey, TValue> and IDictionary<TKey, TValue>) as a valid batch DataLoader return type, and updates docs/tests accordingly.
Changes:
- Accept
Task<Dictionary<TKey, TValue>>/ValueTask<Dictionary<TKey, TValue>>as valid batch DataLoader return types in analyzer validation. - Add/adjust analyzer tests and snapshots to cover valid/invalid
Dictionary<TKey, TValue>return types (including group loading). - Update HotChocolate documentation to reflect the expanded return-type contract.
File summaries
| File | Description |
|---|---|
| website/content/docs/hotchocolate/fetching-data/batching/dataloader.md | Documents Dictionary<TKey, TValue> as an allowed batch DataLoader return type and updates the group-loading example. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/GenericDataLoaderAnalyzerTests.cs | Adds valid/invalid Dictionary<TKey, TValue> return-type scenarios for the generic DataLoader analyzer. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/DataLoaderTests.cs | Updates the generic contract test matrix to treat Task<Dictionary<,>> as a valid batch DataLoader contract. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/GenericDataLoaderAnalyzerTests.ValidGenericDataLoaderContracts_DoNotRaiseDiagnostics.md | Updates generated-source snapshot to include DataLoaders based on Dictionary<TKey, TValue> return types. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/GenericDataLoaderAnalyzerTests.InvalidGenericDataLoaderContracts_RaiseExpectedDiagnostics.md | Updates diagnostics snapshot message and adds new invalid-dictionary-key/value cases. |
| src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/GenericDataLoaderAnalyzerTests.ByRefGenericDataLoaderReturns_RaiseExpectedDiagnostics.md | Updates diagnostics snapshot message to include Dictionary<TKey, TValue> as an allowed type (for the non-byref requirement cases). |
| src/HotChocolate/Core/src/Types.Analyzers/Models/GenericDataLoaderInfo.cs | Updates the generator-side type checks to treat Dictionary<TKey, TValue> as an acceptable batch return dictionary shape. |
| src/HotChocolate/Core/src/Types.Analyzers/GenericDataLoaderAnalyzerHelper.cs | Updates analyzer helper validation to allow Dictionary<TKey, TValue> return types for batch contracts. |
| src/HotChocolate/Core/src/Types.Analyzers/DataLoaderReturnTypeAnalyzer.cs | Updates the reported diagnostic message for invalid batch return types to include Dictionary<TKey, TValue>. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0
- Review effort level: Lite
💡 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.
No description provided.