chore: make connection paging more like standard
This commit is contained in:
@@ -6,8 +6,9 @@ type Connection @goModel(model: "github.com/sour-is/ev/pkg/gql.Connection") {
|
||||
edges: [Edge!]!
|
||||
}
|
||||
input PageInput @goModel(model: "github.com/sour-is/ev/pkg/gql.PageInput") {
|
||||
idx: Int = 0
|
||||
count: Int = 30
|
||||
after: Int = 0
|
||||
before: Int
|
||||
count: Int = 30
|
||||
}
|
||||
type PageInfo @goModel(model: "github.com/sour-is/ev/pkg/gql.PageInfo") {
|
||||
next: Boolean!
|
||||
|
||||
@@ -38,19 +38,30 @@ type PageInfo struct {
|
||||
}
|
||||
|
||||
type PageInput struct {
|
||||
Idx *int64 `json:"idx"`
|
||||
Count *int64 `json:"count"`
|
||||
After *int64 `json:"after"`
|
||||
Before *int64 `json:"before"`
|
||||
Count *int64 `json:"count"`
|
||||
}
|
||||
|
||||
func (p *PageInput) GetIdx(v int64) int64 {
|
||||
if p == nil || p.Idx == nil {
|
||||
return v
|
||||
if p == nil {
|
||||
// pass
|
||||
} else if p.Before != nil {
|
||||
return (*p.Before)
|
||||
} else if p.After != nil {
|
||||
return *p.After
|
||||
}
|
||||
return *p.Idx
|
||||
|
||||
return v
|
||||
}
|
||||
func (p *PageInput) GetCount(v int64) int64 {
|
||||
if p == nil || p.Count == nil {
|
||||
return v
|
||||
} else if p.Before != nil {
|
||||
return -(*p.Count)
|
||||
} else if p.After != nil {
|
||||
return *p.Count
|
||||
}
|
||||
|
||||
return *p.Count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user