Documentation
¶
Overview ¶
Package connections implement a generic GraphQL relay connection
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connection ¶
func Connection[NodeType any, EdgeType Edge, ConType any]( source []NodeType, edgeMaker EdgeMaker[NodeType], conMaker ConMaker[NodeType, EdgeType, ConType], input models.ConnectionInput) (*ConType, error)
Connection will paginate a source according to the input of a relay connection
func CursorToOffset ¶
CursorToOffset re-derives the offset from the cursor string.
func OffsetToCursor ¶
OffsetToCursor create the cursor string from an offset
Types ¶
type ConMaker ¶
type ConMaker[NodeType any, EdgeType Edge, ConType any] func( edges []*EdgeType, nodes []NodeType, info *models.PageInfo, totalCount int) (*ConType, error)
ConMaker defines a function that creates a ConnectionType
type Edge ¶
type Edge interface {
GetCursor() string
}
Edge define the contract for an edge in a relay connection
type EdgeMaker ¶
EdgeMaker defines a function that takes a NodeType and an offset and create an Edge.
type LazyBugEdge ¶
LazyBugEdge is a special relay edge used to implement a lazy loading connection
func (LazyBugEdge) GetCursor ¶
func (lbe LazyBugEdge) GetCursor() string
GetCursor return the cursor of a LazyBugEdge
type LazyIdentityEdge ¶
LazyIdentityEdge is a special relay edge used to implement a lazy loading connection
func (LazyIdentityEdge) GetCursor ¶
func (lbe LazyIdentityEdge) GetCursor() string
GetCursor return the cursor of a LazyIdentityEdge