-
Notifications
You must be signed in to change notification settings - Fork 1
/
page_info_resolver.go
41 lines (32 loc) · 1.25 KB
/
page_info_resolver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package paging
import (
"context"
)
// PageInfoResolver interface
type PageInfoResolver interface {
HasPreviousPage(ctx context.Context, pageInfo *PageInfo) (bool, error)
HasNextPage(ctx context.Context, pageInfo *PageInfo) (bool, error)
TotalCount(ctx context.Context, pageInfo *PageInfo) (*int, error)
StartCursor(ctx context.Context, pageInfo *PageInfo) (*string, error)
EndCursor(ctx context.Context, pageInfo *PageInfo) (*string, error)
}
type pageInfoResolver struct{}
// NewPageInfoResolver returns the resolver for PageInfo
func NewPageInfoResolver() PageInfoResolver {
return &pageInfoResolver{}
}
func (r *pageInfoResolver) TotalCount(ctx context.Context, pageInfo *PageInfo) (*int, error) {
return pageInfo.TotalCount()
}
func (r *pageInfoResolver) HasPreviousPage(ctx context.Context, pageInfo *PageInfo) (bool, error) {
return pageInfo.HasPreviousPage()
}
func (r *pageInfoResolver) HasNextPage(ctx context.Context, pageInfo *PageInfo) (bool, error) {
return pageInfo.HasNextPage()
}
func (r *pageInfoResolver) StartCursor(ctx context.Context, pageInfo *PageInfo) (*string, error) {
return pageInfo.StartCursor()
}
func (r *pageInfoResolver) EndCursor(ctx context.Context, pageInfo *PageInfo) (*string, error) {
return pageInfo.EndCursor()
}