ChilliCream / ChilliCream/graphql-platform

Support for sorting and projections on filtered relation count

Open
#6,006 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Data Area: Projections
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?

No

The solution you'd like

Hi -
I would like to have the option to get count of filtered relations, and also sort on that count

Given the following EF schema:

Class A
{
    public string Id {get;set;}
    public string FieldA1 {get;set;}
    public string FieldA2 {get;set;}
    public IReadOnlyCollection<B> BList {get;set;}
}

class B
{
    public string Id {get;set;}
    public string FieldB1 {get;set;}
    public string FieldB2 {get;set;}
}

class Query
{
    public IQueryable<A> GetAllA();
}

i would like to be able to query using the following graphql request:

query {
  repositories (
      order: [{bCount:  ASC /* sort by the filter of bCount*/}]
  )
      {
    items {
        id
        fieldA1
        
        bCount(where: {fieldB: {some - filter})
      }
    totalCount
 }

I was looking through the docs and didn't find a native way to achieve this
Can i achieve this with the existing features?

Thanks!

Contributor guide

Open the contributing guide

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.

Research direction

Start by reviewing Hot Chocolate’s existing relation filtering, projection, and ordering documentation; the issue names no files or tests. Confirm whether filtered relation counts and ordering are supported for the shown EF-backed schema, then define acceptance coverage for the requested GraphQL query.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.