v8-archive icon indicating copy to clipboard operation
v8-archive copied to clipboard

Add ability to sort by field in GraphQL

Open LeeroyJenks opened this issue 4 years ago • 5 comments

I don't know if it's something I just can't find, but I haven't been able to find a way to sort my query by fields on GraphQL

I'm building a simple blog, and currently I have to manually order the posts each time using the sort field. I'd like to have posts ordered so that most recent is first. I may be overcomplicating things.

Currently I have something like:

posts {
  data {
    id
    created_on
    sort_order
    title
  }
}

but I'd like to be able to order like so:

posts(sort:{ order: DESC, fields: created_on }) {
  data {
    id
    created_on
    sort_order
    title
  }
}

Is this possible? Does it already exist and I just can't figure out how to do it?

LeeroyJenks avatar Mar 09 '20 18:03 LeeroyJenks

I highly support this even though I know Directus v9 is in the pipes and might bring this functionality alive.

flayks avatar Jul 09 '20 08:07 flayks

Any updates on this?

classicalguss avatar Sep 13 '20 11:09 classicalguss

Absolutely a MUST. I can't even sort blog posts by date of creation and this a very basic feature.

jvmonjo avatar Sep 28 '20 20:09 jvmonjo

Are there any updates on this?

fveracoechea avatar Sep 29 '20 20:09 fveracoechea

We will be including this in the upcoming v9 release, but the core team will not be adding this to v8.

benhaynes avatar Sep 29 '20 21:09 benhaynes