Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some details to hasNextPage/hasPreviousPage descriptions. #673

Merged
merged 2 commits into from
Apr 19, 2017
Merged

Add some details to hasNextPage/hasPreviousPage descriptions. #673

merged 2 commits into from
Apr 19, 2017

Conversation

tiegz
Copy link
Contributor

@tiegz tiegz commented Apr 12, 2017

According to the Relay spec, the hasNextPage and hasPreviousPage fields in PageInfo require first or last arguments to be meaningful:

hasPreviousPage is only meaningful when last is included, as it is always false otherwise. hasNextPage is only meaningful when first is included, as it is always false otherwise. When both first and last are included, both of the fields are set according to the above algorithms, but their meaning as it relates to pagination becomes unclear. This is among the reasons that pagination with both first and last is discouraged.

(NB this was decided for performance purposes)

Since this can cause some confusion from getting a meaningless false value back, I propose we mention this in these fields' descriptions.

@rmosolgo
Copy link
Owner

Sorry for the delay on this, these descriptions were originally added for parity with the JS implementation.

It seems like the best thing is to bring some i18n-like framework to graphql so that users can customize the built-in messages, but that's a big effort 😅 . I'm not sure if we should deviate from JS in the meantime or not.

@tiegz
Copy link
Contributor Author

tiegz commented Apr 18, 2017

i18n sounds good for the future! I'd be happy to help if you need some assistance with that.

Also wanna throw out there that the graphl-relay-js library's descriptions for these implies the forward/backward direction too: https://github.com/graphql/graphql-relay-js/blob/373f2dab5fc6d4ac4cf6394aa94cbebd8cb64650/src/connection/connection.js#L133-L153

@rmosolgo
Copy link
Owner

Thanks for the link, I guess I mis-remembered the bit about matching their descriptions! What do you think about taking the descriptions from JS? I'd be happy to merge that.

@tiegz
Copy link
Contributor Author

tiegz commented Apr 18, 2017

Sounds good! Just pushed that change.

@rmosolgo rmosolgo merged commit 8f79bfe into rmosolgo:master Apr 19, 2017
@rmosolgo
Copy link
Owner

Thanks, sweet!

@rmosolgo rmosolgo modified the milestone: 1.5.8 Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants