-
Say I have an ordinary "blog entries by date" that is queried using Relay-style cursor based pagination, and i have a UI where users can scroll through the blog entries in a virtual list. Each blog entry has an opaque string cursor. Since there are a lot of blog entries, I'd like to make an interface so users can "jump to a date" and start scrolling at a specific date -- and be able to scroll both backwards and forwards from that date. To implement this, I'm thinking i'd make an extra query to find the cursor of the first entry on or after that date, and then refetch the main blog query starting at that cursor. That way, the main query remains a query for all blog posts, and I've just moved the window to the cursor the user wants, and they can scroll forward and backward by date. I know the cursor is not predictable, but my question is, does the second query generate the same cursor for the same blog entry that the original query (all posts) would generate for the identical blog entry? Or are cursors for queries unique to the query, so that Query 1's cursor for post_ID 2021 is different from Query 2's cursor for the same post_ID 2021? (This seems to be really a question about how opaque cursors are generated in the Relay spec, but i couldn't find the answer in the spec. Maybe the implementation differs in different environments, and this is the right place for the question. Hopefully this is a question someone can answer off the top of their head.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi! No, there's no guarantee that an object will have the same cursor in different queries. Here's why:
As such, cursors are really opaque, server-provided tokens for moving forward and backward in the same query. For stable object identifiers that work from query to query, you'd probably want |
Beta Was this translation helpful? Give feedback.
Hi! No, there's no guarantee that an object will have the same cursor in different queries. Here's why: