-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update startCursor and endCursor in Connections.md spec #2655
Conversation
Allow `PageInfo`'s `startCursor` and `endCursor` to be null; required for empty results.
Note that similar to #2819, you should run |
Any reason this was not merged yet? I got super confused by the spec not allowing null values. |
same, please update spec to provide an answer |
Yes please! This confused the hell out of me. |
If you make the |
@krvajal What else besides A type system doesn't enforce and guarantee correctness in all situations. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Bump |
Maybe |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The spec is still lagging implementations here (a.k.a. "bump") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve this change 👍
Besides the general consensus in this thread, here's some (permalinks for posterity) links to Relay's codebase on main
to back it up:
- Relay's types treat startCursor/endCursor as nullable:
export type PageInfo = { endCursor: ?string, hasNextPage: boolean, hasPreviousPage: boolean, startCursor: ?string, ... }; - Relay's "GraphQL Server Specification" uses them as nullable in the example:
relay/website/docs/guides/graphql-server-specification.md
Lines 69 to 74 in 8ac91d7
type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String endCursor: String } - There's tests on main that assert that the cursors are null:
relay/packages/relay-runtime/handlers/connection/__tests__/ConnectionHandler-test.js
Lines 701 to 710 in ec03bf4
'client:4:__ConnectionQuery_friends_connection(orderby:["first name"]):pageInfo': { [ID_KEY]: 'client:4:__ConnectionQuery_friends_connection(orderby:["first name"]):pageInfo', [TYPENAME_KEY]: 'PageInfo', [END_CURSOR]: null, [HAS_NEXT_PAGE]: false, [HAS_PREV_PAGE]: false, [START_CURSOR]: null, },
It's clear to me that startCursor/endCursor should be nullable, are treated as nullable by Relay, and are generally implemented in the community as nullable. The specification should reflect this de facto reality.
@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
The spec is not updated yet. I think this PR should be re-opened and most likely merged. |
connection spec hasn't been updated yet facebook/relay#2655
This is very frustrating. Could we reopen and merge this PR? |
@lughino @alphec This pull request changed the file at https://github.com/facebook/relay/blob/main/website/spec/Connections.md#introspection-2 But https://relay.dev/graphql/connections.htm has not been re-rendered from that source file. This has come up before #2457. It appears that I missed the significance of #2655 (comment). However, including the html changes in addition to the source file changes would probably have resulted in undesired merge conflicts over the 3 years it took to merge this pull request. |
Thanks @ngbrown for raising the new PR |
Summary: This PR just runs `yarn update-spec` in the website package in order to get the spec site back in sync with the current version of the spec. Includes updates from #2655 Pull Request resolved: #4109 Reviewed By: lumapat Differential Revision: D40803673 Pulled By: alunyov fbshipit-source-id: 3b54b7b83a7e2f15f61a203af8cc54e7059f9bc1
connection spec hasn't been updated yet facebook/relay#2655
connection spec hasn't been updated yet facebook/relay#2655
connection spec hasn't been updated yet facebook/relay#2655
connection spec hasn't been updated yet facebook/relay#2655
Actual usage requires that
startCursor
andendCursor
are nullable for empty results.This is reflected in #2122 and implemented in a17b462.