Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#10,754 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #10760 by @tobias-tengler — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Start with the minimal reproduction linked in the issue and compare the IQueryable resolver with the resolver that applies QueryContext using .With(...). Inspect how QueryContext.Sorting is built from ISortingContext fields, especially the expression-based total field. Done means QueryContext.Sorting includes that sort and the reported orderings work for both resolvers.

Written by the indexing model from the issue text.

Description

🌶️ hot chocolate
Product

Hot Chocolate

Version

16.8.0-p7

Link to minimal reproduction

https://github.com/paramamue/hc_sorting

Steps to reproduce

Clone the repo, then run dotnet run. A few queries get executed with different orderings.

The class Item has a custom SortInputType with an expression field total.
There are two resolvers:

  • GetItemsQueryable returns IQueryable
  • GetItemsQueryContext return IEnumerable and injects a QueryContext and applies it manually using .With(...)
What is expected?

All orderings work for both resolvers.

What is actually happening?

With the resolver that directly returns IQueryable<Item>, all orderings work fine.
For the resolver using the QueryContext, orderings on the total field are not applied. QueryContext.Sorting is missing that field.
The ISortingContext is always correct.

Relevant log output
=== order: [{ total: DESC }]
IQueryable middleware: {"data":{"itemsQueryable":[{"name":"C"},{"name":"A"},{"name":"B"}]}}
QueryContext:          {"data":{"itemsQueryContext":[{"name":"B"},{"name":"C"},{"name":"A"}]}}
  ISortingContext.GetFields(): total
  QueryContext.Sorting:        []

=== order: [{ total: DESC }, { name: ASC }]
IQueryable middleware: {"data":{"itemsQueryable":[{"name":"C"},{"name":"A"},{"name":"B"}]}}
QueryContext:          {"data":{"itemsQueryContext":[{"name":"A"},{"name":"B"},{"name":"C"}]}}
  ISortingContext.GetFields(): total, name
  QueryContext.Sorting:        [t => t.Name ASC]

=== order: [{ name: DESC }]
IQueryable middleware: {"data":{"itemsQueryable":[{"name":"C"},{"name":"B"},{"name":"A"}]}}
QueryContext:          {"data":{"itemsQueryContext":[{"name":"C"},{"name":"B"},{"name":"A"}]}}
  ISortingContext.GetFields(): name
  QueryContext.Sorting:        [t => t.Name DESC]
Additional context

Repros on latest stable and latest preview.

Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
14h 55m
Merged PRs (30d)
208

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ChilliCream/graphql-platform

All issues in ChilliCream/graphql-platform

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.