Pagination and Phoenix Contexts

I’m wondering how people handle the concern of paginating results in ecto and phoenix context. In my opinion the contexts should not really be concerned with how pagination, but if the Repo.… are part of the context something in the context still needs to have some way to manipulate the query before the Repo is called.

In a layered architecture this would be the concern a level above the business logic, but I’m not sure how things would be passed around in that case. E.g. passing around ecto queries would somehow make everything aware of ecto.

2 Likes

For read-only operations, I don’t mind just exposing some query building functions to the controller.

I created json_api_query_builder for those query heavy APIs.

1 Like

Ok, so simply just another public interface module. That’s an idea I have been toying with as well and I probably like the most by now.

Yes, like a small step towards a CQRS design.