Skip to content

Commit

Permalink
allow using "page" for connection pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissm79 committed Jul 1, 2016
1 parent 902b98f commit 8b74b8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Support/Definition/RelayConnectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public static function connectionArgs()
],
'last' => [
'type' => Type::int()
],
'page' => [
'type' => Type::int(),
]
];
}
Expand Down
3 changes: 2 additions & 1 deletion src/Support/Traits/RelayConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function scopeGetConnection($query, array $args)
{
$first = isset($args['first']) ? $args['first'] : 15;
$after = $this->decodeCursor($args);
$currentPage = $first && $after ? floor(($first + $after) / $first) : 1;
$page = isset($args['page']) ? $args['page'] : 1;
$currentPage = $first && $after ? floor(($first + $after) / $first) : $page;

return $query->paginate($first, ['*'], 'page', $currentPage);
}
Expand Down

0 comments on commit 8b74b8c

Please sign in to comment.