vt-elixir / ja_resource

A behaviour to reduce boilerplate code in your JSON-API compliant Phoenix controllers without sacrificing flexibility.
Other
113 stars 33 forks source link

[Question] Changing behaviors to include pagination by default #54

Closed RaphSfeir closed 7 years ago

RaphSfeir commented 7 years ago

I am currently using ja_serializer with scrivener for pagination on my lists (index) endpoints, everything is working smoothly, thanks for a great tool.

What would be a good way of using ja_resource without giving up my pagination feature, and at the same time not using boilerplate code for the pagination on every controller?

I was thinking of changing directly the JaResource.Index behavior, using Repo.paginate there, would it be a good approach or is it better to do this on my my app instead of the JaResource dependency?

alanpeabody commented 7 years ago

Please see: https://hexdocs.pm/ja_resource/0.2.0/JaResource.Index.html#c:handle_index_query/2

You can define this in module and include via use in your application if implementing it in each controller is too much.