{"action":"closed","issue":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/192","repository_url":"https://api.github.com/repos/rmosolgo/graphql-ruby","labels_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/192/labels{/name}","comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/192/comments","events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/192/events","html_url":"https://github.com/rmosolgo/graphql-ruby/issues/192","id":166747838,"number":192,"title":"Q: UnionType and base fields (feature request?)","user":{"login":"elado","id":51488,"avatar_url":"https://avatars.githubusercontent.com/u/51488?v=3","gravatar_id":"","url":"https://api.github.com/users/elado","html_url":"https://github.com/elado","followers_url":"https://api.github.com/users/elado/followers","following_url":"https://api.github.com/users/elado/following{/other_user}","gists_url":"https://api.github.com/users/elado/gists{/gist_id}","starred_url":"https://api.github.com/users/elado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elado/subscriptions","organizations_url":"https://api.github.com/users/elado/orgs","repos_url":"https://api.github.com/users/elado/repos","events_url":"https://api.github.com/users/elado/events{/privacy}","received_events_url":"https://api.github.com/users/elado/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-07-21T06:38:03Z","updated_at":"2016-07-21T18:23:51Z","closed_at":"2016-07-21T18:23:51Z","body":"Let's say you can like multiple object types, `Post` and `Comment`:\r\n\r\n```rb\r\nLikableUnion = GraphQL::UnionType.define do\r\n  name 'Likable'\r\n  description '..'\r\n  possible_types [PostType, CommentType]\r\nend\r\n```\r\n\r\nBoth `PostType` and `CommentType` have `likeCount` field. I want to avoid writing fragments for each type:\r\n\r\n```graphql\r\nmutation LikeItem($input:LikeItemInput!) {\r\n  likeItem(input:$input) {\r\n    item {\r\n      ... on Post {\r\n        id\r\n        likeCount\r\n      }\r\n      ... on Comment {\r\n        id\r\n        likeCount\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nBut instead, grab the `likeCount` and `id` directly from the `item`:\r\n\r\n```graphql\r\nmutation LikeItem($input:LikeItemInput!) {\r\n  likeItem(input:$input) {\r\n    item {\r\n      id\r\n      likeCount\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nIs there a way to declare fields on UnionType? Didn't see that option in the source."}}
{"actor":{"display_login":"elado"}}