QueryContext<T>.Sorting drops expression-based sort fields
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
- Domain
- backend-api-design
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
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
QueryContextand 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
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ChilliCream/graphql-platform
-
Make `TryInferSchemaType` on `IDescriptorContext` public for use in custom type discovery handlersOpen🌶️ hot chocolate
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ChilliCream/graphql-platform#10569 ·
Maintainers usually reply within 1 day
-
🌶️ hot chocolate
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ChilliCream/graphql-platform#10567 ·
Maintainers usually reply within 1 day
-
HC16: @defer with incremental delivery v0.1 exposes a lifetime race that can cause persistent high CPUPossibly taken @michaelstaib claimed this 1 day ago. Open🌶️ hot chocolate
ChilliCream/graphql-platform#10668 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
🌶️ strawberry shake
Difficulty 5/5 Over a week Newbie friendliness 35/100
ChilliCream/graphql-platform#10643 ·
Maintainers usually reply within 1 day
-
🌶️ strawberry shake
Difficulty 3/5 1-2 days Newbie friendliness 76/100
ChilliCream/graphql-platform#10570 ·
Maintainers usually reply within 1 day
All issues in ChilliCream/graphql-platform
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 2 days
-
bug effort:S P3
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
nightscout/nocturne#3093 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day