facebook / facebook/relay

GraphQL Cursor Connections Specification return Nodes without Edges

Open
#3,850 1 comment 20 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

The Modern Relay in the GraphQL Cursor Connections Specification explains that Edge's cursor is not used.

> As this spec was created with Relay Classic in mind, it’s worth noting that Relay Legacy did not define startCursor and endCursor, and relied on selecting the cursor of each edge; Relay Modern began selecting startCursor and endCursor instead to save bandwidth (since it doesn’t use any cursors in between).
> https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo.Fields

If that's the case, we don't need Edge, and why not just return an array of Node?
I feel that Edge is an unnecessary type hierarchy.

If the GraphQL Cursor Connections Specification does not change, it is difficult for the client library utility to support Nodes.
https://www.apollographql.com/docs/react/pagination/cursor-based/#relay-style-cursor-pagination

## Schema samples

GitHub and Shopify Admin API returns an array of Node in the Connection.

| GitHub | Shopify |
| ---- | ---- |
| shopify | github |
|スクリーンショット 2022-05-18 20 30 48 |スクリーンショット 2022-05-18 20 31 29|

https://shopify.dev/api/release-notes/2022-04

> Improvements to GraphQL connections
As of API version 2022-04, we've added a nodes field on the Connection object. When you only query node on edges, you can simplify the query. We've also added the startCursor and endCursor fields on the PageInfo object, which allows you to simplify the shape of return data for pagination.
>
>For more information, refer to Paginating results with GraphQL.
>
>New fields
>
>nodes field was added to Connection object
>startCursor field was added to PageInfo object
>endCursor field was added to PageInfo object

Contributor guide

Open the contributing guide

Research direction

Start with the GraphQL Cursor Connections Specification, the Relay Modern PageInfo fields, and the Apollo relay-style pagination guidance cited in the issue. Done means reaching an agreed direction on nodes-only connections and identifying the Relay changes required; the issue names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.