{"action":"created","issue":{"url":"https://api.github.com/repos/prisma/prisma/issues/4027","repository_url":"https://api.github.com/repos/prisma/prisma","labels_url":"https://api.github.com/repos/prisma/prisma/issues/4027/labels{/name}","comments_url":"https://api.github.com/repos/prisma/prisma/issues/4027/comments","events_url":"https://api.github.com/repos/prisma/prisma/issues/4027/events","html_url":"https://github.com/prisma/prisma/issues/4027","id":408581195,"node_id":"MDU6SXNzdWU0MDg1ODExOTU=","number":4027,"title":"Go Client: Implement Relay Connections ","user":{"login":"steebchen","id":5013932,"node_id":"MDQ6VXNlcjUwMTM5MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/5013932?v=4","gravatar_id":"","url":"https://api.github.com/users/steebchen","html_url":"https://github.com/steebchen","followers_url":"https://api.github.com/users/steebchen/followers","following_url":"https://api.github.com/users/steebchen/following{/other_user}","gists_url":"https://api.github.com/users/steebchen/gists{/gist_id}","starred_url":"https://api.github.com/users/steebchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steebchen/subscriptions","organizations_url":"https://api.github.com/users/steebchen/orgs","repos_url":"https://api.github.com/users/steebchen/repos","events_url":"https://api.github.com/users/steebchen/events{/privacy}","received_events_url":"https://api.github.com/users/steebchen/received_events","type":"User","site_admin":false},"labels":[{"id":1053240175,"node_id":"MDU6TGFiZWwxMDUzMjQwMTc1","url":"https://api.github.com/repos/prisma/prisma/labels/area/client/go","name":"area/client/go","color":"fbca04","default":false},{"id":502077932,"node_id":"MDU6TGFiZWw1MDIwNzc5MzI=","url":"https://api.github.com/repos/prisma/prisma/labels/kind/feature","name":"kind/feature","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2019-02-10T21:21:41Z","updated_at":"2019-09-19T14:25:17Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"**Describe the bug**\r\nConnections are currently not supported in the Go client. Some types already exist (Edge, PageInfo...), but the functions are not implemented yet.\r\n\r\n**To Reproduce**\r\nCreate a single-to-many relation between User and Post:\r\n```graphql\r\ntype User {\r\n\tid: ID! @unique\r\n\temail: String! @unique\r\n\tname: String!\r\n\tposts: [Post!]!\r\n}\r\n\r\ntype Post {\r\n\tid: ID! @unique\r\n\tuser: User!\r\n\ttitle: String!\r\n\tcontent: String!\r\n}\r\n```\r\n\r\nGenerate the Prisma client and access it:\r\n```go\r\nfunc (r *queryResolver) Feed(ctx context.Context) ([]prisma.Post, error) {\r\n\tconn, err := r.Prisma.PostsConnection(&prisma.PostsConnectionParams{}).Exec(ctx)\r\n\t// conn is a struct with no further methods and PostsConnections panics\r\n}\r\n```\r\n\r\n**Next steps**\r\n\r\nAn actual implementation is missing for the connection methods. Also, some structs are empty.\r\n\r\n```\r\nfunc (client *Client) PostsConnection(params *PostsConnectionParams) PostConnectionExec {\r\n\tpanic(\"not implemented\")\r\n}\r\n\r\n...\r\n\r\ntype PostConnection struct {\r\n}\r\n```\r\n\r\nrelated: https://github.com/prisma/prisma/blob/214389359b94de9abec44e43110b70df46d2046a/cli/packages/prisma-client-lib/src/codegen/generators/go-client.ts#L588"},"comment":{"url":"https://api.github.com/repos/prisma/prisma/issues/comments/533155116","html_url":"https://github.com/prisma/prisma/issues/4027#issuecomment-533155116","issue_url":"https://api.github.com/repos/prisma/prisma/issues/4027","id":533155116,"node_id":"MDEyOklzc3VlQ29tbWVudDUzMzE1NTExNg==","user":{"login":"steebchen","id":5013932,"node_id":"MDQ6VXNlcjUwMTM5MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/5013932?v=4","gravatar_id":"","url":"https://api.github.com/users/steebchen","html_url":"https://github.com/steebchen","followers_url":"https://api.github.com/users/steebchen/followers","following_url":"https://api.github.com/users/steebchen/following{/other_user}","gists_url":"https://api.github.com/users/steebchen/gists{/gist_id}","starred_url":"https://api.github.com/users/steebchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steebchen/subscriptions","organizations_url":"https://api.github.com/users/steebchen/orgs","repos_url":"https://api.github.com/users/steebchen/repos","events_url":"https://api.github.com/users/steebchen/events{/privacy}","received_events_url":"https://api.github.com/users/steebchen/received_events","type":"User","site_admin":false},"created_at":"2019-09-19T14:25:17Z","updated_at":"2019-09-19T14:25:17Z","author_association":"CONTRIBUTOR","body":"It seems it is not so easy to implement an extra nodes field because how this works internally. However, it would be easy to add a .Nodes() method to the Connection struct, which would also mean the user can optionally convert edges to nodes but only if needed. It would look like this:\r\n\r\n```\r\nconn, err := x.UsersConnection(...).Exec(ctx)\r\n\r\n// conn is UserConnection{Edges: []UserEdge, PageInfo: PageInfo}\r\nlog.Printf(\"%+v\", conn.PageInfo)\r\nlog.Printf(\"%+v\", conn.Edges)\r\n\r\n// here I want to return nodes, so I can do\r\nreturn conn.Nodes()\r\n```\r\n\r\nI think this is actually a good solution. What do you think @soqt? also @chris-rock"}}
{"actor":{"display_login":"steebchen"}}