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
Relay returning too many connection edges from QueryRenderer #2570
Comments
can you share code that was working and now is not working anymore? |
@sibelius @josephsavona For sure! Here you go: https://github.com/ekosz/relay-pagination-bug Currently, this repo still has a bug where the compat doesn't render its results? I don't think its related at all, but at least the modern version is showing the bug absolutely. I'm going to continue trying to get compat to work. |
(whoops, sorry about the accidental close/missclick) So I traced the relay code and I found out why compat isn't rendering. This line is erroring out https://github.com/facebook/relay/blob/master/packages/react-relay/classic/store/RelayStoreData.js#L775 because That means a A fix on the relay side would be to change that line of code to if (!Object.prototype.hasOwnProperty.call(response, serializationKey)) { But I'll see if there's anything I can do for my demo in the meantime |
@ekosz Is your test case passing results directly from |
I think the issue here is that for Modern you’re using |
@josephsavona Do you know of a "blessed" implementation of a windowed paginator using I guess what we could do it track both the start and end cursor that we're looking for. Then just iterate the list until we find the start custor and continuing until the end cursor is found. Does that sound correct? |
@ekosz I'm not aware of one. Note that
|
you should start from here https://github.com/facebook/relay/blob/master/packages/relay-runtime/handlers/connection/RelayConnectionHandler.js#L46 to create a new handler |
you can slice edges in your component until you figure it out how to implement a custom RelayConnectionHandler you could have a hook like this const { edges } = useRelayPagination({ connection: myConnection }) |
I guess you were ahead of time on this one 😂 |
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. |
I get work cursor based pagination like windowed pagination getting the total count of items with that I get the number of pages, and the page you click * number of items per page, and calls the query with variable first = page number * number of items per page and pass also last with the number of items per page. Example 100 items 20 per page 5 pages click page 3 it will 3 * 20 = 60 this value it will be first and last 20 you get the items from 40 to 60. |
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. |
Hi there. I'm trying to build a windowed pagination component and I've discovered a regression(?) when upgrading from compat to modern.
Because Relay doesn't support windowed pagination natively, I implemented it using
QueryRenderer
s manually keeping track of theendCursor
. This worked with a compatQueryRenderer
, but once I upgraded to modern this stopped working as expected.In this first screenshot you can see what the
QueryRenderer
is returning in terms of props. This is the first "page" after requesting the first 2 edges in the connection.In this next screenshot you can see that we are requesting the next "page" which is the next 2 edges in the connection after the
endCursor
of the prev "page".What happened in compat
We would receive props which only contained only the two new edges. This is exactly what we requested and what we want.
What's happening in modern
We are actually receiving 4 edges. The 2 from the prev page and the 2 from the next page of results. This makes is so that instead of windowed pagination we are instead making it a infinitely growing list.
This doesn't seem like the correct behavior. I would expect that we would only get props related to the variables I gave the
QueryRenderer
not additional edges that wasn't part of the request / response from the server.The text was updated successfully, but these errors were encountered: