docs: add package godoc and clarify public API

Prepare the extracted library for external consumption with grouped
godoc, extension point docs, and setup requirements. Wire
ErrBadCursorString into decode paths and drop redundant Paginate*Conds
aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 17:14:05 -07:00
parent aecd90eb84
commit 683b0ddbf4
8 changed files with 141 additions and 59 deletions
+2 -3
View File
@@ -22,8 +22,7 @@ type PageInfo struct {
StartCursor *string `json:"startCursor,omitempty"`
}
// CursorFunc is a function that takes a pointer to an object type T, the
// underlying database view object, and returns a GenericCursor or an error.
// CursorFunc builds a [GenericCursor] for a connection node.
type CursorFunc[T any] = func(*T) (GenericCursor, error)
// Edge represents a single edge in a connection, containing a node of type T
@@ -85,7 +84,7 @@ func BuildEdges[T any](
pageInfo.EndCursor = &edges[len(edges)-1].Cursor
// Fetch total count. Comparisons use composite tuple logic when the cursor
// encodes both order and index columns (see meeting pagination).
// encodes both order and index columns.
startCursor, err := cursorFunc(edges[0].Node)
if err != nil {
return nil, fmt.Errorf("failed to get start cursor: %w", err)