Documentation
¶
Overview ¶
Package connections implement a generic GraphQL relay connection
Index ¶
- func Connection[NodeType any, EdgeType Edge, ConType any](source []NodeType, edgeMaker EdgeMaker[NodeType], ...) (*ConType, error)
- func CursorToOffset(cursor string) (int, error)
- func OffsetToCursor(offset int) string
- type ConMaker
- type CursorEdge
- type Edge
- type EdgeMaker
- type LazyBugEdge
- type LazyIdentityEdge
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 CursorEdge ¶ added in v0.11.0
type CursorEdge struct {
Cursor string
}
CursorEdge is a minimal edge carrying only a cursor. Use it with connections.Connection when the edge type needs no additional fields.
func (CursorEdge) GetCursor ¶ added in v0.11.0
func (e CursorEdge) GetCursor() string
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