diff --git a/src/Support/Definition/PageInfoType.php b/src/Support/Definition/PageInfoType.php index 373159740e..d9d4a53057 100644 --- a/src/Support/Definition/PageInfoType.php +++ b/src/Support/Definition/PageInfoType.php @@ -54,7 +54,7 @@ public function fields() if ($collection instanceof LengthAwarePaginator) { return $this->encodeGlobalId( 'arrayconnection', - $collection->firstItem() * $collection->currentPage() + $collection->currentPage() ); } @@ -66,10 +66,11 @@ public function fields() 'description' => 'When paginating forwards, the cursor to continue.', 'resolve' => function ($collection) { if ($collection instanceof LengthAwarePaginator) { - return $this->encodeGlobalId( - 'arrayconnection', - $collection->lastItem() * $collection->currentPage() - ); + $cursor = $collection->hasMorePages() + ? $collection->lastItem() + : $collection->currentPage(); + + return $this->encodeGlobalId('arrayconnection', $cursor); } }, ],