pagination icon indicating copy to clipboard operation
pagination copied to clipboard

Support for `join`/`alsoDecode`

Open Cellane opened this issue 6 years ago • 4 comments

Motivation Behind Feature

At this moment, unless I’m mistaken, Pagination needs to operate on a QueryBuilder that produces Future<[Model]>. That makes it unable to paginate results that also fetch data from a different table, by using the Fluent’s join(_:to:)/alsoDecode(_:) methods, as these change the eventual output of QueryBuilder to Future<[(ModelA, ModelB)]>.

Feature Description

It would be awesome if we could paginate even these slightly more complicated queries. I get a feeling that the eventual implementation would have to also rely on an implementation of #11 that would allow us to specify how should the end result be joined for a valid JSON representation.

Alternatives or Workarounds

None considered or thought of.

Cellane avatar Jul 30 '18 00:07 Cellane

I've not given this much thought as it's not crossed my mind, however, I do see how this would be a need for some people. I'll look into implementing something like this, but if you do have any ideas, feel free to submit PR

anthonycastelli avatar Aug 02 '18 04:08 anthonycastelli

I think this would be a very welcoming addition. Personally, I have an example of a /feed route that should return a heterogeneous array of feed items with different types.

If we had support for something like @Cellane proposes, then we don't have to do a weird dance of type erasure in order to support decoding/encoding of that heterogeneous array and instead rely on the multi-type pagination to return a result including a separate array for every type.

damirstuhec avatar Aug 17 '18 02:08 damirstuhec

Just wanted to circle back to these issues and say I haven't forgotten about them. Just been swamped lately so haven't had a chance to work on anything regarding these packages. 🙂

anthonycastelli avatar Sep 03 '18 17:09 anthonycastelli

Any progress here?

gperdomor avatar Dec 06 '18 14:12 gperdomor