ChilliCream / ChilliCream/graphql-platform
Allow filtering and sorting on dictionary properties when using MartenDB provider
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Hot Chocolate
Is your feature request related to a problem?
The following is a valid MartenDB query and works if invoking manually
public class Player
{
public required Dictionary<Skill, int?> Skills { get; set; } = new();
}
await using var session = store.QuerySession();
return session
.Query<Player>()
.Where(x => x.Skills[Skill.Pace] > 85)
.OrderByDescending(x => x.Skills[Skill.Pace]);
This does not however work when invoking from hot chocolate query
skills: { all: { key: { eq: PACE }, value: { gt: 85 } } }
"extensions": {
"message": "Property 'Demo.Skill Key' is not defined for type 'Demo.Skill' (Parameter 'property')",
}
There also seems no way of sorting on the keys of the dictionary since the dictionary is not defined as sortable even though all other properties on the document is sortable
The solution you'd like
It would be nice if there would be an similar approach of achieving this
Filtering
skills: { all: { key: { eq: PACE } value: { gt: 85 } } }
Sorting
order: [{ skills: { key: PACE direction: DESC }]
Contributor 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.
Research direction
The issue names no files or tests. Start by reproducing the MartenDB provider query with dictionary filtering and sorting, then trace Hot Chocolate's filtering and sorting integration for dictionary properties. Done means the shown filtering and sorting GraphQL shapes work for the Skills dictionary without the reported property error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100