OffsetCursor

value class OffsetCursor(val value: String)(source)

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: String holds the encoded cursor string (e.g., "X192aWFkdWN0OmlkeDow")

  • toOffset() decodes the cursor string to get the offset Int

  • fromOffset(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()

Constructors

Link copied to clipboard
constructor(value: String)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The encoded cursor string (Base64 encoded)

Functions

Link copied to clipboard
fun toOffset(): Int

Decode this cursor to get the offset value.