Sort from relational record field

System Information
  • Strapi Version: 4.3.2
  • Operating System: Nix
  • Database: Postgres 14 and sqlite
  • Node Version: 16

I have an Article collection type that is related to a Tag collection type. An article can have many tags and a tag can have many articles. I want to be able to pull back all articles associated with a tag and then sort by the publishedAt field on the Article.

For example to pull all Articles for a tag would be

/api/tags?filters[slug]=test123&populate=*

Will pull back all articles with the tag of test123. I have tried to pass a sort to that, the query runs but nothing is sorted

api/tags?filters[slug]=test123&populate=*&sort=articles.publishedAt:desc

I have tried searching and seen several post about the 3.x version of Strapi but haven’t seen anyone with this issue on 4.x. So I am sure I am missing something.

1 Like