News for hackers. Stuff that matters.
Re:GraphQL Is a Trap? by masklinn on Friday May 06, 2022 @11:31AM (#31286345)
I think you misunderstood the issue. Of course you will use variables for the pagination itself, the issue is that your head of line query will be grabbing other fields than the paginated one.

You don't want to repeat these fetches in the followup queries, they're redundant, and assuming the API is rate-limited they will decrease your query budget for no value.

That counts double if you're fetching multiple paginated fields (which also adds to the awkwardness).

Re:GraphQL Is a Trap? by obi1kenobi on Friday May 06, 2022 @11:37AM (#31286411)
Agreed — consider what happens when you have a node(start: Int, limit: Int) inside or alongside another such node with start and limit.

Your pagination is now two-dimensional, with each node's start/limit as points on its own axis.

Now add a third node to the query. Now you have three-dimensional pagination. This quickly goes off the rails.

Try writing a generic N-dimensional paginator for such a query to see why it's difficult. Even designing a sensible and reasonably flexible API for one is a headache.

Re:GraphQL Is a Trap? by searchableguy on Friday May 06, 2022 @11:44AM (#31286515)
I think I got what you are saying now. If you want to get paginated children nodes, then the root will be fetched again which is a problem.
Re:GraphQL Is a Trap? by masklinn on Friday May 06, 2022 @01:08PM (#31287519)
Indeed. It may not be a huge problem depending on how much data you need, but there are lots of cases where you'd really rather avoid refetching the rest of the root.

TBF you could also deal with it using fragments I think, but still, not great.