nestjs-query
nestjs-query copied to clipboard
Nested sorting
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:
- https://github.com/doug-martin/nestjs-query/issues/559
- https://github.com/doug-martin/nestjs-query/issues/752
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 https://github.com/doug-martin/nestjs-query/issues/559#issuecomment-713290342 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 https://github.com/doug-martin/nestjs-query/issues/559#issuecomment-713290342
Thanks for pointing out @ValentinVignal, the double underscore makes sense.
By chance @TriPSs have you been able to look at this or have any insights on a preferred approach?
Have not looked at it, __ think it's good, changes of that colliding with other fields should be pretty low.