-
Goal: Create a table that does server-side pagination based on GraphQL relay cursors.
-
Steps:
- I've studied the documentation on GQL relay-based pagination: Optimize queries with server-side pagination | Retool Docs.
- To reproduce the problem, implement a GQL relay API that doesn't calculate hasNext page when paging backwards, and try to connect it to a Retool table.
-
Details:
I've defined the inputs to the GQL query based on the Retool table'spagination
field like so:
I've configured the Retool table's pagination like so:
There are a few problems here:
- I have to write some logic involving
beforeCursor
in order to determine what parameters to pass to the GQL query because the Retool table doesn't separatelast
fromfirst
. (As stated in Retool's documentation linked above but without an example or specifics on what that logic should look like.) - Because my API doesn't calculate
hasNextPage
when paging backwards--as the Connection specification allows--I have to add some logic to "has next page", usingbeforeCursor
to know that there's a next page after I paginate backwards. - AFAICT the semantics of
beforeCursor
are undocumented, which means that I can't be certain that my implementation of the first two bullet points is correct.
I think that Retool could make its support for GQL relay-based pagination a lot better by simply requiring the user to populate a pageInfo
field for the Retool table to read and by giving the Retool table a pagination
property to pass to the GQL query. The query and the Retool table could each assume that pageInfo
and pagination
are Javascript objects that match the Cursor Connection specification and act accordingly.