storefront-api-examples icon indicating copy to clipboard operation
storefront-api-examples copied to clipboard

Support for Relay Modern

Open dhmacs opened this issue 6 years ago • 12 comments

I've tried to use the Relay Modern pagination container, but it is not possible since in the API PageInfo scheme is missing the endCursor and startCursor fields.. Any plan to add these to the Storefront API any time soon?

dhmacs avatar Jul 12 '17 15:07 dhmacs

This seems like a bug in Relay Modern. The actual Relay spec doesn't say those fields are required: https://facebook.github.io/relay/graphql/connections.htm#sec-undefined.PageInfo.Fields

swalkinshaw avatar Jul 12 '17 17:07 swalkinshaw

@swalkinshaw That's why I have opened an issue to the relay repo too, but I think the spec document is out of date. For example, Github API already supports this (see Github PageInfo schema type)

dhmacs avatar Jul 12 '17 22:07 dhmacs

Glad you opened an issue. Here's a little more background: https://stackoverflow.com/a/34951162

swalkinshaw avatar Jul 13 '17 00:07 swalkinshaw

@swalkinshaw that post has more than a year and a half, and given that Relay is quickly evolving I don't think is still valid. Every working example I've found on Relay Modern pagination uses endCursor and startCursor under PageInfo.. Here a few examples:

  • https://facebook.github.io/relay/docs/graphql-relay-specification.html
  • https://stackoverflow.com/questions/44113029/relay-modern-load-more-is-not-working-hasmore-keep-returning-false
  • http://www.persatuan-pangkas-rambut-garut.com/anggaran/dasar/ad.cgi/en/00/https/stackoverflow.com/questions/44321127/i-cannot-do-loadmore-in-relay-even-there-are-more-items

I think it would be awesome if you could provide a working example of pagination with Relay Modern in this repo. Meanwhile I hope to get a clarification on this matter from the Relay folks

dhmacs avatar Jul 13 '17 11:07 dhmacs

If/when the official Relay spec is updated to include those fields, we'll add them as well.

I think it would be awesome if you could provide a working example of pagination with Relay Modern in this repo.

That isn't possible unless they remove the requirement of those fields right?

I'll leave this issue open to track the status of Relay.

swalkinshaw avatar Jul 14 '17 15:07 swalkinshaw

@swalkinshaw is it still correct to assume Relay isn't compatible with the storefront api?

richardscarrott avatar Jun 05 '18 21:06 richardscarrott

It still appears that way after a quick check.

I found https://github.com/facebook/relay/issues/2457 as well.

swalkinshaw avatar Jun 05 '18 21:06 swalkinshaw

apollo-client it is then! Thanks.

richardscarrott avatar Jun 06 '18 18:06 richardscarrott

@swalkinshaw i think they have just updated official spec: https://github.com/facebook/relay/blob/83ad928200e3f484a5208884c6c7059609e880d1/website/spec/Connections.md#pageinfo-1

janisrove avatar Jul 11 '19 16:07 janisrove

@swalkinshaw any updates on this?

tothandras avatar Oct 28 '19 11:10 tothandras

+1

0xHexE avatar Aug 12 '21 06:08 0xHexE

Hi Everyone,

I think now startCursor and endCursor is required. I am using relay version 11.0.2. And I am getting the following error.

image

0xHexE avatar Aug 12 '21 06:08 0xHexE