Skip to content

Support for sorting and projections on filtered relation count  #6006

@elad-legit

Description

@elad-legit

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions