I'm working on a GraphQL API and am using Relay style cursor navigation.
I have come across an issue that I can't seem to find anyone else with, which is strange as it seems to be a common UI pattern.
That is if you fetch your item from the list you can retrieve its cursor and navigate forwards and backwards easily.
For example, imagine you selected an item from a paginated list and are taken to that item's specific page, here I can easily determine which item comes before and after this and can show buttons to allow you to navigate forwards and backwards because I have the item's cursor.
If you however where then to refresh that item's page, I would have to query the item by its unique ID (assuming that is all the URL contains) and I would not know its cursor within that connection, I would have to worst case enumerate the entire connection to find it to render a simple backwards or forwards button.
Is there a suggested way in relay cursor navigation to allow you to find an item's position within that connection without having to enumerate the entire connection?
Even if not suggested has anyone got a good solution to this problem?
So far I have two possible solutions:
Generating the cursor from the item's ID so that someone is able to generate a cursor for it having only the item, I'm not sure what downsides that may bring though.
Adding separate previous and next fields to the node and allowing the backend to compute it separately when requested.