TriPSs/nestjs-query

Nested sorting

ValentinVignal opened this issue · 5 comments

Is your feature request related to a problem? Please describe.

There were some issues on https://github.com/doug-martin/nestjs-query about being able to sort by nested fields:

which could be super helpful. I would like to be able to sort a list of Todos by their linked project name:

query myTodos {
  todos(
    # Sort by project name here
  ) {
    id # ID!
    name  # String!
    completed # Boolean!
    project {  # Project!
      id # ID!
      name # String!
    }
  }
}

In my case, I only have the need for "one-to-one" or "one-to-many" relationships (1 todo won't be linked to multiple projects)

Have you read the Contributing Guidelines?

Yes

Describe the solution you'd like

The solution offered doug-martin/nestjs-query#559 (comment) was not too bad:

TodoSortFields {
  id
  name
  project__id
  project__name
}

Describe alternatives you've considered
Writing my own custom resolver where I can implement my own sorting.

Separating the table from the column using a . might be better syntax.

Separating the table from the column using a . might be better syntax.

I don't think that possible, see this comment doug-martin/nestjs-query#559 (comment)

Thanks for pointing out @ValentinVignal, the double underscore makes sense.