Best approach to deep sorting and filtering in GraphQL

Hi,

I’ve been using Strapi for some time now and I’m pretty happy overall, but there are some unsupported features which I had to create workarounds for in order to have them, and now I find myself stuck with new problems.

I’m specially missing custom sorting of content-types, and the workaround for it creates new problems regarding deep sorting and filtering. From what I’ve read, I understand it’s because of the relational models Strapi uses.

In order to create a content-type custom sorting feature, I had to create a dynamic zone where there are repeatable relational components. This way, the admin can arrange items in any order easily (not drag & drop but almost).

By the way, I use GraphQL for the queries.

The problem comes when I want to use some deep filtering, like let’s say limit the number of query entries. You can’t use “limit”, “sort”, etc on components nor in dynamic zones.

And here comes my scenario: I have a “products” content-type, and a “categories” content-type, both related to each other. Then I have this separate page with a dynamic zone where you can arrange “products” in the dynamic zone to create somewhat an custom order. Now I need to create a “pagination” system where I get 30 items per page. Since I cannot use limits or offsets on components, I haven’t found a way to solve this. And I’m afraid once I get too many products, the query will become unmanageable.

The perfect solution would be that the content-types had a custom order feature, where you drag & drop and reorder them at your own will. This way, I could just go through products content-type and sort them by this field, limit and offset them. I also though about creating myself a field for the ordering, but with a lot of products it becomes unusable, even using a 10-20-30 technique.

What would be the best approach to solve this? Have you encountered something similar, and how did you fix it?

Any help or ideas will be appreciated! Thanks.