I have a mutation that reorders two edges in a relay connection. What is the right way to perform this reordering optimistically? I've tried an in-place sort like:
const conn = ConnectionHandler.getConnection(pathway, 'PathwayGraph_actions');
const edges = conn.getLinkedRecords('edges');
edges.sort((a, b) => {
const laneA = a.getLinkedRecord('node').getValue('laneNumber');
const laneB = b.getLinkedRecord('node').getValue('laneNumber');
return laneA - laneB;
});
This doesn't seem to work. I suspect relay tries pretty hard to not allow store mutations except through its interface. I suppose I could use ConnectionHandler to delete all the existing edges, and then add them all back in the proper order, but that sounds quite cumbersome. Is there a better way?