We have a connection that can return a node twice (a user's listening history - i.e. you can listen to the same show twice). I realise that the name "connection" implies that each edge is to a unique node, but does that have to be the case? The cursor pagination is useful for all types of lists.
The warnings we get in this case are:
Attempted to add an ID already in GraphQLSegment
Attempted to add noncontiguous index to GraphQLSegment: 11 to (0, 9)
This is because the edge ID is generated by:
var edgeID = require('./generateClientEdgeID')(connectionID, nodeID);
A potential solution might be to get the cursor into the edgeID?
Happy to be told that you don't think connections should be used for this - there are other solutions such as duplicating the pagination functionality or changing the data model (in this case we could have connection -> edge -> listen -> show) but if there's no reason why connection nodes have to be unique fixing that would be the easiest solution!
Currently, we expect the nodes to be unique. This is because GraphQLSegment is also trying to support the find call and uses the node id in a couple other places. However, that might change in the future. For right now, I think what you suggested with changing the data model is perfect connection -> edge -> listen -> show.
@yuzhi can we improve the warning message to point out the exactly nodes that have duplicated keys?
Most helpful comment
@yuzhi can we improve the warning message to point out the exactly nodes that have duplicated keys?