Skip to content

Fix QueryContext sorting dropping expression-based sort fields - #10773

Merged
michaelstaib merged 2 commits into
mainfrom
mst/issue-10754
Nov 2, 2026
Merged

michaelstaib merged 2 commits into
mainfrom
mst/issue-10754

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #10754

Copilot AI balanced review requested due to automatic review settings November 1, 2026 09:11

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.

🟢 Approval recommended

No active review issues are blocking approval of the sorting change.

No open issues 🎉

What changed in this PR

Fixes QueryContext sorting so expression-defined fields are preserved when converting sorting input into a sort definition.

Changes:

  • Builds selectors from expression metadata, validates lambda parameters, and supports method-backed fields.
  • Reuses the existing parameter-replacement visitor.
  • Adds a regression test verifying that expression-based and property-based sort fields are both retained in order.
File Description
src/​HotChocolate/​Data/​test/​Data.Sorting.Tests/​Context/​SortingContextTests.cs Tests mixed expression-based and property-based sorting.
src/​HotChocolate/​Data/​src/​Data/​Sorting/​Expressions/​Handlers/​QueryableDefaultSortFieldHandler.cs Makes the parameter-replacement visitor available internally for reuse.
src/​HotChocolate/​Data/​src/​Data/​Sorting/​Context/​SortingContext.cs Preserves expression-defined sort selectors and handles method-backed fields.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

80.0% of changed lines covered (12/15)

File Covered Changed Patch %
…/HotChocolate/Data/src/Data/Sorting/Context/SortingContext.cs 12 15 80.0% 🟡
Uncovered changed lines (JSON)
{
  "sha": "de5f1d5e9568dfca06cd1e9507015295701272a7",
  "files": [
    { "path": "src/HotChocolate/Data/src/Data/Sorting/Context/SortingContext.cs", "ranges": [[224, 225], [237, 237]] }
  ]
}

Project coverage: 59.3% (319210/538368 lines)

@michaelstaib
michaelstaib merged commit 8a148b4 into main Nov 2, 2026
159 checks passed
@michaelstaib
michaelstaib deleted the mst/issue-10754 branch November 2, 2026 08:41
This was referenced Nov 10, 2026
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.

QueryContext<T>.Sorting drops expression-based sort fields

2 participants