paginators

package
v0.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2023 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package paginators handles pagination logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaginatedResponse

type PaginatedResponse interface {
	GetPageInfo() *types.PageInfo
}

PaginatedResponse interface helps the generic paginator to get information from a resource-specific paginator.

type Paginator

type Paginator struct {
	NextCursor *string // nil means no next page unless hasDoneQuery is false
	// contains filtered or unexported fields
}

Paginator is the generic paginator struct with methods.

One quirk of the go-graphql-client is it requires a _FRESH_ query structure for each page. Otherwise, the second page panics in reflect with a slice index out of range.

func NewPaginator

func NewPaginator(queryCallback func(ctx context.Context, after *string) (interface{}, error)) Paginator

NewPaginator creates a brand-new paginator.

func (*Paginator) HasMore

func (p *Paginator) HasMore() bool

HasMore tells whether a paginator has more pages to read. If no page has not yet been read, it will return true, even if the page will be empty.

func (*Paginator) Next

func (p *Paginator) Next(ctx context.Context) (interface{}, error)

Next returns the next page of results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL