You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADE-0.12.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,3 +35,48 @@ UPGRADE FROM 0.11 to 0.12
35
35
App\GraphQL\:
36
36
resource: ../GraphQL
37
37
```
38
+
39
+
40
+
### Relay Paginator, Connections & Edges
41
+
42
+
- Following the [paginator update](docs/helpers/relay-paginator.md) and the use of interfaces for Relay Connection & Edge, getters & setters must be use to manipulate Connection, Edge and PageInfo Properties
43
+
44
+
Before :
45
+
46
+
```php
47
+
$connection->edges = $edges;
48
+
$connection->totalCount = 10;
49
+
...
50
+
$edge->cursor = $cursor;
51
+
$edge->node = $node;
52
+
53
+
```
54
+
55
+
After :
56
+
57
+
```php
58
+
$connection->setEdges($edges);
59
+
$connection->setTotalCount(10);
60
+
...
61
+
$edge->setCursor($cursor);
62
+
$edge->setNode($node);
63
+
```
64
+
65
+
Connection builder method are no more accessible statically:
66
+
67
+
Before:
68
+
69
+
```php
70
+
use Overblog\GraphQLBundle\Relay\Connection\ConnectionBuilder;
71
+
72
+
ConnectionBuilder::connectionFromArray([]);
73
+
```
74
+
75
+
After:
76
+
77
+
```php
78
+
use Overblog\GraphQLBundle\Relay\Connection\ConnectionBuilder;
Copy file name to clipboardExpand all lines: docs/helpers/relay-paginator.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,3 +261,53 @@ public function resolveList($args)
261
261
return $pagination->forward($args);
262
262
}
263
263
```
264
+
265
+
266
+
#### Customize the way the connection & edges are built
267
+
268
+
Sometimes, you want to add fields to your Connection or Edges. In order to do so, you'll have to pass a custom instance of `ConnectionBuilder` to your Paginator as follow:
269
+
270
+
```php
271
+
use Overblog\GraphQLBundle\Relay\Connection\ConnectionBuilder;
$paginator = new Paginator(function ($offset, $limit) use ($backend) {
289
+
return $backend->getData($offset);
290
+
}, true, $connectionBuilder);
291
+
}
292
+
```
293
+
294
+
The `ConnectionBuilder` constructor accepts two parameters. The first one is a callback to build the Connection object, and the second one is a callback to build an Edge object.
295
+
296
+
The connection callback will be call with the following parameters :
297
+
298
+
-`edges` An array of edges object implementing `Overblog\GraphQLBundle\Relay\Connection\EdgeInterface`
299
+
-`pageInfo` a PageInfo object `Overblog\GraphQLBundle\Relay\Connection\Output\PageInfo`
300
+
301
+
This callback MUST return an instance of `Overblog\GraphQLBundle\Relay\Connection\ConnectionInterface`
302
+
303
+
304
+
The edge callback will be call with the following parameters :
305
+
306
+
-`cursor` The cursor
307
+
-`value` A value returned by the paginator data fetcher
308
+
-`index` The index of the value
309
+
310
+
This callback MUST return an instance of `Overblog\GraphQLBundle\Relay\Connection\EdgeInterface`
311
+
312
+
If no callback are specified for the `ConnectionBuilder`, it'll generate instance of `Overblog\GraphQLBundle\Relay\Connection\Output\Connection` and `Overblog\GraphQLBundle\Relay\Connection\Output\Edge`
0 commit comments