graphql / graphql/graphql-relay-js

pageInfo.hasPreviousPage is always false if you are paging forwards

Open
#58 20 comments 25 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.5k
Forks
177
Avg merge
10m
Merged PRs (30d)
1

Description

https://github.com/graphql/graphql-relay-js/blob/7422cfe8ccd1c2cd3923c7e1d5f8b7533c0e3fdd/src/connection/arrayconnection.js#L120

If my connection args don't have the 'last' parameter, then hasPreviousPage will always be false. Same problem if you are paging backwards and don't have the 'first' parameter in your connection args: hasNextPage will always be false.

But I can't have a 'last' parameter if I am paging forward using 'first' and 'after'. And I can't have a 'first' parameter if I am paging backwards using 'last' and 'before'. Babel-relay-plugin will throw an error on transpile.

So if I am paging forwards, I will always be told I have no previous pages, even when I do. And if I am paging backwards I will always be told I have no next pages, even when I do.

This has gotta be a bug. It kinda ruins bi-directional paging.

Can't we just make paging easier and let us pass first and last and before and after all as connection args (some of them as null depending on which way you are paging) without babel-relay-plugin blowing up?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.