Skip to content

Commit e8e8ed2

Browse files
authored
Merge pull request #245 from Ciloe/fix_paginator
Fix paginator auto totalCount when using promise
2 parents 2e758e0 + 1fab748 commit e8e8ed2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Relay/Connection/Paginator.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(callable $fetcher, $promise = self::MODE_REGULAR)
5050
* @param int|callable $total
5151
* @param array $callableArgs
5252
*
53-
* @return Connection
53+
* @return Connection|object A connection or a promise
5454
*/
5555
public function backward($args, $total, array $callableArgs = [])
5656
{
@@ -73,7 +73,7 @@ public function backward($args, $total, array $callableArgs = [])
7373
/**
7474
* @param Argument|array $args
7575
*
76-
* @return Connection
76+
* @return Connection|object A connection or a promise
7777
*/
7878
public function forward($args)
7979
{
@@ -105,7 +105,7 @@ public function forward($args)
105105
* @param int|callable $total
106106
* @param array $callableArgs
107107
*
108-
* @return Connection
108+
* @return Connection|object A connection or a promise
109109
*/
110110
public function auto($args, $total, $callableArgs = [])
111111
{
@@ -118,14 +118,16 @@ public function auto($args, $total, $callableArgs = [])
118118
}
119119

120120
if ($this->promise) {
121-
$connection->then(function (Connection $connection) use ($total, $callableArgs) {
121+
return $connection->then(function (Connection $connection) use ($total, $callableArgs) {
122122
$connection->totalCount = $this->computeTotalCount($total, $callableArgs);
123+
124+
return $connection;
123125
});
124126
} else {
125127
$connection->totalCount = $this->computeTotalCount($total, $callableArgs);
126-
}
127128

128-
return $connection;
129+
return $connection;
130+
}
129131
}
130132

131133
/**

0 commit comments

Comments
 (0)