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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user