Skip to content

Cache the enum value literal for variable coercion - #10537

Merged
tobias-tengler merged 2 commits into
mainfrom
tte/enum-value-literal
Oct 13, 2026
Merged

tobias-tengler merged 2 commits into
mainfrom
tte/enum-value-literal

Conversation

@tobias-tengler

Copy link
Copy Markdown
Member

No description provided.

Variable coercion created a new EnumValueNode for every coerced enum value.
EnumValue holds its literal from completion on and FusionEnumValue from
construction on, and both coercions return it. The HotChocolate enum value
collection caches the frozen dictionary's span lookup instead of fetching it
per hashed lookup, and the Fusion enum value collection gets a byte-span
TryGetValue so the coercion can reach the value.
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (23/23)

File Covered Changed Patch %
…/src/Types/Execution/Processing/VariableCoercionHelper.cs 1 1 100.0% 🟢
src/HotChocolate/Core/src/Types/Types/Contracts/EnumValue.cs 2 2 100.0% 🟢
src/HotChocolate/Core/src/Types/Types/EnumValueCollection.cs 2 2 100.0% 🟢
…/Collections/FusionEnumValueCollection.cs 12 12 100.0% 🟢
…/Fusion/src/Fusion.Execution.Types/FusionEnumValue.cs 2 2 100.0% 🟢
…/src/Fusion.Execution/Execution/JsonVariableCoercion.cs 4 4 100.0% 🟢

Project coverage: 58.7% (315922/538339 lines)

@tobias-tengler
tobias-tengler marked this pull request as ready for review October 13, 2026 16:41
Copilot AI balanced review requested due to automatic review settings October 13, 2026 16:41

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tobias-tengler
tobias-tengler merged commit 787471c into main Oct 13, 2026
158 checks passed
@tobias-tengler
tobias-tengler deleted the tte/enum-value-literal branch October 13, 2026 16:54
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