{"action":"created","issue":{"url":"https://api.github.com/repos/overblog/GraphQLBundle/issues/412","repository_url":"https://api.github.com/repos/overblog/GraphQLBundle","labels_url":"https://api.github.com/repos/overblog/GraphQLBundle/issues/412/labels{/name}","comments_url":"https://api.github.com/repos/overblog/GraphQLBundle/issues/412/comments","events_url":"https://api.github.com/repos/overblog/GraphQLBundle/issues/412/events","html_url":"https://github.com/overblog/GraphQLBundle/issues/412","id":375109211,"node_id":"MDU6SXNzdWUzNzUxMDkyMTE=","number":412,"title":"Relay Connection, Paginator & Connection builder","user":{"login":"Vincz","id":400525,"node_id":"MDQ6VXNlcjQwMDUyNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/400525?v=4","gravatar_id":"","url":"https://api.github.com/users/Vincz","html_url":"https://github.com/Vincz","followers_url":"https://api.github.com/users/Vincz/followers","following_url":"https://api.github.com/users/Vincz/following{/other_user}","gists_url":"https://api.github.com/users/Vincz/gists{/gist_id}","starred_url":"https://api.github.com/users/Vincz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vincz/subscriptions","organizations_url":"https://api.github.com/users/Vincz/orgs","repos_url":"https://api.github.com/users/Vincz/repos","events_url":"https://api.github.com/users/Vincz/events{/privacy}","received_events_url":"https://api.github.com/users/Vincz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-29T16:38:48Z","updated_at":"2018-10-29T21:03:19Z","closed_at":null,"author_association":"NONE","body":"| Q                | A\r\n| ---------------- | -----\r\n| Bug report?      | no\r\n| Feature request? | yes\r\n| BC Break report? | no\r\n\r\n<!--\r\nPlease fill in this template according to your issue.\r\n-->\r\n\r\nHey guys,\r\nI have a question regarding the relay connections implementation. \r\nAs describe in the docs, we are able to define connections & edges with additional fields using the `relay-connection` type.\r\nBut, tell me if I'm wrong, but the Paginator doesn't handle this custom fields as it use the final classes `Connection` and `Edge`. \r\nWhat about adding a little bit of flexibility ? \r\nWe could for example add the ability to define custom classes for the connection and the edge, and callbacks, to populate the connection if needed (after the edges resolved) to add new field to the connection (some calculated fields based on the edges or whatever), and the same way to populate Edges (with custom fields).\r\n\r\nSo we could add a `ConnectionInterface` and an `EdgeInterface` to ensure the relay fields, and add the ability to pass a custom `ConnectionBuilder` to the Paginator (by default it would be `new ConnectionBuilder()`, so we should use it as an instanciated class and not a static one).\r\n\r\nSo the api could look like this for example:  \r\n\r\n```php\r\n\r\n$connectionBuilder = new ConnectionBuilder( \r\nfunction($edges, PageInfo $pageInfo) : FriendsConnection {\r\n    $connection = new FriendsConnection($edges, $pageInfo)\r\n    $connection->setAverageAge(calculateAverage($edges));\r\n    return $connection;\r\n},\r\nfunction(string $cursor, UserFriend $entity):FriendEdge {\r\n   $edge = new FriendEdge($cursor, $entity->getUser());\r\n   $edge->setFriendshipTime($entity->getCreatedAt());\r\n   return $edge;\r\n});\r\n\r\n$paginator = new Paginator(function ($offset, $limit) use ($backend) {\r\n    return $backend->getData($offset);\r\n}, true, $connectionBuilder);\r\n\r\n$result = $paginator->auto(...);\r\n```\r\n\r\nPlease, tell me what you think :) \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/overblog/GraphQLBundle/issues/comments/434079046","html_url":"https://github.com/overblog/GraphQLBundle/issues/412#issuecomment-434079046","issue_url":"https://api.github.com/repos/overblog/GraphQLBundle/issues/412","id":434079046,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDA3OTA0Ng==","user":{"login":"calvera","id":432090,"node_id":"MDQ6VXNlcjQzMjA5MA==","avatar_url":"https://avatars1.githubusercontent.com/u/432090?v=4","gravatar_id":"","url":"https://api.github.com/users/calvera","html_url":"https://github.com/calvera","followers_url":"https://api.github.com/users/calvera/followers","following_url":"https://api.github.com/users/calvera/following{/other_user}","gists_url":"https://api.github.com/users/calvera/gists{/gist_id}","starred_url":"https://api.github.com/users/calvera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calvera/subscriptions","organizations_url":"https://api.github.com/users/calvera/orgs","repos_url":"https://api.github.com/users/calvera/repos","events_url":"https://api.github.com/users/calvera/events{/privacy}","received_events_url":"https://api.github.com/users/calvera/received_events","type":"User","site_admin":false},"created_at":"2018-10-29T21:03:19Z","updated_at":"2018-10-29T21:03:19Z","author_association":"NONE","body":":+1: "}}
{"actor":{"display_login":"calvera"}}