Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Split enum value sorting from field sorting - #9711

#9711
Merged
michaelstaib merged 3 commits into
mainChilliCream/graphql-platform:mainfrom
mst/enum-sortChilliCream/graphql-platform:mst/enum-sortCopy head branch name to clipboard
May 16, 2026
Merged

Split enum value sorting from field sorting#9711
michaelstaib merged 3 commits into
mainChilliCream/graphql-platform:mainfrom
mst/enum-sortChilliCream/graphql-platform:mst/enum-sortCopy head branch name to clipboard

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

Fixes #9708

Copilot AI review requested due to automatic review settings May 15, 2026 21:43

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.

Pull request overview

Fixes regression where SortFieldsByName = true also sorted enum values in v16. Introduces a separate SortEnumValuesByName option (default false), restoring v15 behavior while still allowing opt-in enum sorting.

Changes:

  • Adds SortEnumValuesByName to IReadOnlySchemaOptions / SchemaOptions and a corresponding OrderEnumValuesByName to SchemaFormatterOptions.
  • Updates EnumType initialization and SchemaFormatter to sort enum values based on the new option (decoupled from field sorting).
  • Adds tests and an introspection snapshot covering the new behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs Adds SortEnumValuesByName to the read-only options interface.
src/HotChocolate/Core/src/Types/SchemaOptions.cs Adds the mutable property and propagates it in FromOptions.
src/HotChocolate/Core/src/Types/StoreGlobalSchemaOptionsTypeInterceptor.cs Forwards the new option into SchemaFormatterOptions.
src/HotChocolate/Core/src/Types/Types/EnumType.Initialization.cs Sorts enum values during type completion only when the new option is true.
src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaFormatterOptions.cs Adds OrderEnumValuesByName and updates OrderFieldsByName doc.
src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaFormatter.cs Uses the new option when ordering enum values during formatting.
src/HotChocolate/Core/test/Types.Tests/Types/EnumTypeTests.cs Adds tests for the new option (incl. introspection).
src/HotChocolate/Core/test/Types.Tests/Types/snapshots/EnumTypeTests.SortEnumValuesByName_Should_SortIntrospectionResult.md Snapshot for sorted introspection result.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelstaib
michaelstaib merged commit 4094138 into main May 16, 2026
8 of 9 checks passed
@michaelstaib
michaelstaib deleted the mst/enum-sort branch May 16, 2026 14:20
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.

SchemaOptions.SortFieldsByName now also sorts enum values in v16 (regression vs v15)

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.