{"action":"created","issue":{"url":"https://api.github.com/repos/neelance/graphql-go/issues/28","repository_url":"https://api.github.com/repos/neelance/graphql-go","labels_url":"https://api.github.com/repos/neelance/graphql-go/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/neelance/graphql-go/issues/28/comments","events_url":"https://api.github.com/repos/neelance/graphql-go/issues/28/events","html_url":"https://github.com/neelance/graphql-go/issues/28","id":191601806,"number":28,"title":"Use field as resolver instead of method. ","user":{"login":"nicksrandall","id":1800460,"avatar_url":"https://avatars.githubusercontent.com/u/1800460?v=3","gravatar_id":"","url":"https://api.github.com/users/nicksrandall","html_url":"https://github.com/nicksrandall","followers_url":"https://api.github.com/users/nicksrandall/followers","following_url":"https://api.github.com/users/nicksrandall/following{/other_user}","gists_url":"https://api.github.com/users/nicksrandall/gists{/gist_id}","starred_url":"https://api.github.com/users/nicksrandall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicksrandall/subscriptions","organizations_url":"https://api.github.com/users/nicksrandall/orgs","repos_url":"https://api.github.com/users/nicksrandall/repos","events_url":"https://api.github.com/users/nicksrandall/events{/privacy}","received_events_url":"https://api.github.com/users/nicksrandall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-24T23:25:19Z","updated_at":"2016-11-26T12:48:05Z","closed_at":null,"body":"Would it be possible to use a struct field as a resolver instead of always using methods? Most of my methods are just simple getters so it would be convenient to allow resolver to default to field. Then I could implement method only when I need special logic. "},"comment":{"url":"https://api.github.com/repos/neelance/graphql-go/issues/comments/263061723","html_url":"https://github.com/neelance/graphql-go/issues/28#issuecomment-263061723","issue_url":"https://api.github.com/repos/neelance/graphql-go/issues/28","id":263061723,"user":{"login":"neelance","id":16184,"avatar_url":"https://avatars.githubusercontent.com/u/16184?v=3","gravatar_id":"","url":"https://api.github.com/users/neelance","html_url":"https://github.com/neelance","followers_url":"https://api.github.com/users/neelance/followers","following_url":"https://api.github.com/users/neelance/following{/other_user}","gists_url":"https://api.github.com/users/neelance/gists{/gist_id}","starred_url":"https://api.github.com/users/neelance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neelance/subscriptions","organizations_url":"https://api.github.com/users/neelance/orgs","repos_url":"https://api.github.com/users/neelance/repos","events_url":"https://api.github.com/users/neelance/events{/privacy}","received_events_url":"https://api.github.com/users/neelance/received_events","type":"User","site_admin":false},"created_at":"2016-11-26T12:48:05Z","updated_at":"2016-11-26T12:48:05Z","body":"I have two concerns about this:\r\n\r\n1. Simplicity.\r\nI think that the following happened a lot during the design of the Go language:\r\nIs it possible? Yes.\r\nWould it give the option to write less code? Yes.\r\nShould we add it? Probably not.\r\nAdding this feature does not enable us to do something that we could not do before. It is just a second way to get to the same outcome. Imho this is something that is usually avoided in the Go world. Simplicity is preferred.\r\n\r\n2. Tight coupling between resolver and underlying data structures.\r\nImho resolvers are a view on the underlying data structures. Those data structures can change without changing the GraphQL schema. The resolver can provide legacy fields. By directly accessing struct fields, this distinction becomes less obvious. This can cause the data structures to become more rigid, because people don't want to affect the schema. I think keeping this strong separation makes your GraphQL codebase more healthy in the long term.\r\n"}}
{"actor":{"display_login":"neelance"}}