How to paginate related data in json API?
This is just an example. Say I have Client and Data in many to many relationship. I have a json API to read the clients which defines a related route to read a client's related Data. Since the Data can be quite a lot, I want to force paginating it. I have a paginated read action defined in both Client and Data. However, when I call
http://localhost:4000/api/v1/client/{id}/data
the data is not paginated.
Is this a bug or am I missing something? Here's the relevant code
5 Replies
there's an open issue to support this https://github.com/ash-project/ash_json_api/issues/230
GitHub
Implement pagination feature for related routes · Issue #230 · as...
Problem: The pagination feature is currently not functioning as expected for related routes in the ash_json_api gem. Specifically, when fetching related records for a resource, the records are retu...
Ah, shame. Oh well.
Solution
You can define a read action on the target resource
And put it at that same route
So the resulting API can look the same
Just slightly less convenient
Huh hadn't thought of that
I guess that's as good as it can get for now
I'll mark that as the solution for now