feat: add TotalCount field to PageInfo
test: add TotalCount assertions to existing tests
This commit is contained in:
@@ -99,6 +99,7 @@ func GetPage[T any](items []T, first *int, after *string, last *int, before *str
|
|||||||
HasNextPage: eIx < len(items),
|
HasNextPage: eIx < len(items),
|
||||||
HasPreviousPage: sIx > 0,
|
HasPreviousPage: sIx > 0,
|
||||||
EndCursor: ptr(EncodeCursor(fn(page[len(page)-1]))),
|
EndCursor: ptr(EncodeCursor(fn(page[len(page)-1]))),
|
||||||
|
TotalCount: len(items),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,4 +112,5 @@ type PageInfo struct {
|
|||||||
HasNextPage bool
|
HasNextPage bool
|
||||||
HasPreviousPage bool
|
HasPreviousPage bool
|
||||||
EndCursor *string
|
EndCursor *string
|
||||||
|
TotalCount int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
StartCursor: ptr("MQ=="),
|
StartCursor: ptr("MQ=="),
|
||||||
HasNextPage: true,
|
HasNextPage: true,
|
||||||
EndCursor: ptr("Mg=="),
|
EndCursor: ptr("Mg=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -59,6 +60,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
StartCursor: ptr("MQ=="),
|
StartCursor: ptr("MQ=="),
|
||||||
HasNextPage: false,
|
HasNextPage: false,
|
||||||
EndCursor: ptr("Mw=="),
|
EndCursor: ptr("Mw=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -70,6 +72,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
HasNextPage: false,
|
HasNextPage: false,
|
||||||
HasPreviousPage: true,
|
HasPreviousPage: true,
|
||||||
EndCursor: ptr("NA=="),
|
EndCursor: ptr("NA=="),
|
||||||
|
TotalCount: 4,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -81,6 +84,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
HasNextPage: false,
|
HasNextPage: false,
|
||||||
HasPreviousPage: true,
|
HasPreviousPage: true,
|
||||||
EndCursor: ptr("Mw=="),
|
EndCursor: ptr("Mw=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -92,6 +96,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
HasNextPage: false,
|
HasNextPage: false,
|
||||||
HasPreviousPage: true,
|
HasPreviousPage: true,
|
||||||
EndCursor: ptr("Mw=="),
|
EndCursor: ptr("Mw=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -103,6 +108,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
HasNextPage: true,
|
HasNextPage: true,
|
||||||
HasPreviousPage: false,
|
HasPreviousPage: false,
|
||||||
EndCursor: ptr("Mg=="),
|
EndCursor: ptr("Mg=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -114,6 +120,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
HasNextPage: true,
|
HasNextPage: true,
|
||||||
HasPreviousPage: false,
|
HasPreviousPage: false,
|
||||||
EndCursor: ptr("MQ=="),
|
EndCursor: ptr("MQ=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -125,6 +132,7 @@ func TestGetPage(t *testing.T) {
|
|||||||
HasNextPage: false,
|
HasNextPage: false,
|
||||||
HasPreviousPage: false,
|
HasPreviousPage: false,
|
||||||
EndCursor: ptr("Mw=="),
|
EndCursor: ptr("Mw=="),
|
||||||
|
TotalCount: 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user