|
@@ -6,7 +6,7 @@ import (
|
|
|
)
|
|
|
|
|
|
//easyjson:json
|
|
|
-type PageInfo struct {
|
|
|
+type PageInfo[T connection.Cursor] struct {
|
|
|
Total int `json:"total"`
|
|
|
StartCursor *string `json:"start_cursor,omitempty"`
|
|
|
EndCursor *string `json:"end_cursor,omitempty"`
|
|
@@ -14,12 +14,12 @@ type PageInfo struct {
|
|
|
HasPreviousPage bool `json:"has_previous_page"`
|
|
|
}
|
|
|
|
|
|
-func (pi *PageInfo) SetTotal(nodes []connection.Cursor) {
|
|
|
+func (pi *PageInfo[T]) SetTotal(nodes []T) {
|
|
|
pi.Total = len(nodes)
|
|
|
pi.Invalidate(nodes)
|
|
|
}
|
|
|
|
|
|
-func (pi *PageInfo) Invalidate(nodes []connection.Cursor) {
|
|
|
+func (pi *PageInfo[T]) Invalidate(nodes []T) {
|
|
|
l := len(nodes)
|
|
|
if l < 1 {
|
|
|
pi.HasPreviousPage = pi.StartCursor != nil
|