Order by enum type

I am having a problem ordering by an enum type:

enum Direction {
  forward
  backward
}
type Garage {
  id
  name
  cars: [Car]
  ...
}
type Car {
  id: ID! 
  direction: Direction! @search
  ...
}

And my query:

queryGarage(filter: {id: [$id] } ) {
  id
  name
  cars (order: { asc: direction } ) {
    direction
    name
  }
}

And I get this message:

"input:11: Expected type CarOrderable, found direction.\n"

However, when I do order: { asc: name } I get no problems…

Can I sort by the enum type?

J

2 Likes

You can’t have an index on enums at the moment. So you can’t use it as a sort key. I’m marking this as a feature request.

@hardik will prioritize

4 Likes

Any update on this?