Dependency Cycle in new Table pagination

Hi all,

I'm creating an app with Server Side Limit Offset Based pagination in the new Table component. The datasource of the table is linked to a GetUsers query {{ GetUsers.data.items }}. The pagination total row count is also linked to the same query {{ GetUsers.data.nrOfItems }}.

The query itself uses the table pagination currentPage and pageSize parameters: users/{{usersTable.pagination.currentPage + 1}}/{{usersTable.pagination.pageSize}}?searchString={{ searchString.value }}

The query runs automatically when the inputs change, and when I first start the app I get an error saying: "Dependency Cycle Found: GetUsers -> GetUsers.query -> usersTable.pagination -> usersTable._currentPage -> usersTable._limitOffsetRowCount -> GetUsers.data -> GetUsers.query"

I removed the pagination parameter for debugging purposes and then I don't get that error. So it seems that this is why, but of course I need to know the currentpage to be able to paginate correctly.

2 Likes

Hi @ArnVanhoutte! Thanks for writing in. It seems there's an unintentional dependency cycle with your GetUsers query, since it holds information for both your total row count and your data.

Behind the scenes, currentPage is dependent on the total row count (limitOffsetRowCount) to make sure that your end users don't reach a page that doesn't exist in your server-paginated table. Currently, this creates a dependency cycle between items and total row count.

If you split up {{ GetUsers.data.nrOfItems }} and {{ GetUsers.data.items }} into separate queries, e.g. getUsers and getTotalNumberOfUsers, this should remove the dependency cycle since it separates the two concepts.

Please let me know if this is helpful!

1 Like

Hello,

For efficiency reasons we couldn't really split up the REST API Query in 2 queries. I have managed to "fix" it by setting the {{ GetUsers.data.nrOfItems }} param in a temporary state, and then using that state value in the Table Pagination settings. This gets rid of the error but it feels a bit iffy to me. It'd be nice if the new Table pagination would have a workaround build-in to prevent these dependency errors.

Hi @ArnVanhoutte Thanks for sharing your table feedback & current fix! I'll share this feedback internally :pray: