Offset Cursor
A cursor for offset-based pagination.
OffsetCursor wraps an encoded cursor string that represents a position in a paginated list. The cursor format is: Base64("__viaduct:idx:
Key Design:
value: Stringholds the encoded cursor string (e.g., "X192aWFkdWN0OmlkeDow")toOffset()decodes the cursor string to get the offset IntfromOffset(offset)creates an OffsetCursor by encoding the offset
Usage:
// Create cursor from offset
val cursor = OffsetCursor.fromOffset(42)
// Get the encoded string value for GraphQL response
val cursorString: String = cursor.value // "X192aWFkdWN0OmlkeDo0Mg"
// Decode cursor back to offset
val offset: Int = cursor.toOffset() // 42
// From incoming cursor string
val incomingCursor = OffsetCursor(cursorString)
val decodedOffset = incomingCursor.toOffset()Content copied to clipboard