Skip to content

Commit

Permalink
Merge pull request #65 from nuwave/fix/connection-cursor
Browse files Browse the repository at this point in the history
fix start and end cursors for connection edges
  • Loading branch information
chrissm79 authored Feb 22, 2018
2 parents 2ac5f8b + e6bc8ea commit 6982111
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Support/Definition/PageInfoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function fields()
if ($collection instanceof LengthAwarePaginator) {
return $this->encodeGlobalId(
'arrayconnection',
$collection->firstItem() * $collection->currentPage()
$collection->currentPage()
);
}

Expand All @@ -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);
}
},
],
Expand Down

0 comments on commit 6982111

Please sign in to comment.