Does AshAdmin support pagination?
I want to use AshAdmin. The tables I use contain a couple of 10,000 entries. Too many for a single page. I haven't seen pagination yet. Is it already implemented or is there some config switch which limits the queries?
11 Replies
Yep! You just need to enable pagination on the read action
I am struggling a bit with this. How would I implement that in this code?
I can't find anything about configuring it here on this page
https://hexdocs.pm/ash/pagination.html
Or am I barking at the wrong tree and I have to add this in the LiveView files? Which ones would that be?
Definitely something you want to implement using the core pagination features 🙂
And then you can use
Api.read(…, page: [limit: …])
And there are helpers in AshPhoenix.LiveView to encode/decode to/from params to store pagination params in the irl
**urlFound 2 Guides results in all libraries:
* Pagination: http://ash-hq.org/docs/guides/ash/2.5.9/topics/pagination
* Actions: http://ash-hq.org/docs/guides/ash/2.5.9/topics/actions
wanted to try out the new bot. Can you see the guides it returned? I think its visible to everyone not just me
Thank you!
pagination offset?: true, keyset?: true
made all the difference. It is not my call to make but I think that should be the default. I started the admin interface the first time and nothing happend. It was super sluggish. I thought it was broken. It took me a while to realize that it simply was because I was reading a table with some 40,000 entries and obviously that would become a sluggish webpage.🤔 Yeah, I could see an argument for pagination being the default, but Ash actions are pretty generalized. Not all data layers support limits/offsets in the first place, although that can of course be simulated on top of any data layer
You can also just do
offset?: true
depends on what you want.
It probably won't change in the near future though TBH. Would break a lot of workflows if a bunch of actions all of a sudden were paginatable, mostly because ash_graphql switches on wether or not the view is paginatable to automatically change resolvers to return pagesCould a warning message in the ash_admin GUI be a help for newbies? Something like: "This table contains more than 1,000 rows. It will be slow to work with. Please consider paginating it. See https://documentation."
🤔 Yeah, I think thats a good idea
Perhaps we could even just automatically limit the results to 1000 if its not paginatable and put a message at the top "only showing 1000 results, to show more, make this action paginatable"
That prevents the performance issues and is informative
👍
okay, this is the behavior on main
I can't do a release while ash_admin points at 1.7 rc, but once 1.7 is actually out we can release it