{"action":"created","issue":{"url":"https://api.github.com/repos/artsy/metaphysics/issues/1140","repository_url":"https://api.github.com/repos/artsy/metaphysics","labels_url":"https://api.github.com/repos/artsy/metaphysics/issues/1140/labels{/name}","comments_url":"https://api.github.com/repos/artsy/metaphysics/issues/1140/comments","events_url":"https://api.github.com/repos/artsy/metaphysics/issues/1140/events","html_url":"https://github.com/artsy/metaphysics/pull/1140","id":336148800,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3NjcwMzQ1","number":1140,"title":"[Saleable] Add interface to Artwork & EditionSet.","user":{"login":"alloy","id":2320,"node_id":"MDQ6VXNlcjIzMjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2320?v=4","gravatar_id":"","url":"https://api.github.com/users/alloy","html_url":"https://github.com/alloy","followers_url":"https://api.github.com/users/alloy/followers","following_url":"https://api.github.com/users/alloy/following{/other_user}","gists_url":"https://api.github.com/users/alloy/gists{/gist_id}","starred_url":"https://api.github.com/users/alloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alloy/subscriptions","organizations_url":"https://api.github.com/users/alloy/orgs","repos_url":"https://api.github.com/users/alloy/repos","events_url":"https://api.github.com/users/alloy/events{/privacy}","received_events_url":"https://api.github.com/users/alloy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"mzikherman","id":1457859,"node_id":"MDQ6VXNlcjE0NTc4NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1457859?v=4","gravatar_id":"","url":"https://api.github.com/users/mzikherman","html_url":"https://github.com/mzikherman","followers_url":"https://api.github.com/users/mzikherman/followers","following_url":"https://api.github.com/users/mzikherman/following{/other_user}","gists_url":"https://api.github.com/users/mzikherman/gists{/gist_id}","starred_url":"https://api.github.com/users/mzikherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzikherman/subscriptions","organizations_url":"https://api.github.com/users/mzikherman/orgs","repos_url":"https://api.github.com/users/mzikherman/repos","events_url":"https://api.github.com/users/mzikherman/events{/privacy}","received_events_url":"https://api.github.com/users/mzikherman/received_events","type":"User","site_admin":false},"assignees":[{"login":"mzikherman","id":1457859,"node_id":"MDQ6VXNlcjE0NTc4NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1457859?v=4","gravatar_id":"","url":"https://api.github.com/users/mzikherman","html_url":"https://github.com/mzikherman","followers_url":"https://api.github.com/users/mzikherman/followers","following_url":"https://api.github.com/users/mzikherman/following{/other_user}","gists_url":"https://api.github.com/users/mzikherman/gists{/gist_id}","starred_url":"https://api.github.com/users/mzikherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzikherman/subscriptions","organizations_url":"https://api.github.com/users/mzikherman/orgs","repos_url":"https://api.github.com/users/mzikherman/repos","events_url":"https://api.github.com/users/mzikherman/events{/privacy}","received_events_url":"https://api.github.com/users/mzikherman/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-06-27T09:29:46Z","updated_at":"2018-06-27T18:05:54Z","closed_at":"2018-06-27T15:48:59Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/artsy/metaphysics/pulls/1140","html_url":"https://github.com/artsy/metaphysics/pull/1140","diff_url":"https://github.com/artsy/metaphysics/pull/1140.diff","patch_url":"https://github.com/artsy/metaphysics/pull/1140.patch"},"body":"Yay, our first real interface!\r\n\r\nI’m not sure why the `EditionSet` type is called like that, isn’t each an entry in the set? Anyways, after thinking about `Edition`, `Piece`, etc for a while, I figured I’d go with an adjective form for interfaces as can be found in various examples, e.g. [`Searchable`](https://medium.com/the-graphqlhub/graphql-tour-interfaces-and-unions-7dd5be35de0d). Obviously I then had to choose between the various flavours of English (sellable, saleable, scalable) and settled on the one that seemed the most used in both English and Simplified (US) English.\r\n\r\n----\r\n\r\nThis now allows you to have a fragment on `Saleable` and query any type that implements it:\r\n\r\n```graphql\r\n{\r\n  artwork(id: \"banksy-flower-bomber-by-brandalism\") {\r\n    ...Piece\r\n    edition_sets {\r\n      ...Piece\r\n    }\r\n  }\r\n}\r\n\r\nfragment Piece on Saleable {\r\n  dimensions {\r\n    in\r\n  }\r\n  edition_of\r\n}\r\n```\r\n\r\nMeaning that containers that fetch this data can now be generic:\r\n\r\n```tsx\r\nexport class SizeInfo extends React.Component<SizeInfoProps> {\r\n  render() {\r\n    const {\r\n      piece: { dimensions, edition_of },\r\n    } = this.props\r\n    const dimensionsDescription = dimensions &&\r\n            (dimensions.in || dimensions.cm) &&\r\n            [dimensions.in, dimensions.cm].join(\"; \")\r\n    return (\r\n      <SizeInfoContainer color=\"black60\" textAlign=\"left\">\r\n        <Serif size=\"2\">\r\n          {dimensionsDescription}\r\n        </Serif>\r\n        {edition_of && <Serif size=\"2\">{edition_of}</Serif>}\r\n      </SizeInfoContainer>\r\n    )\r\n  }\r\n}\r\n\r\nexport const SizeInfoFragmentContainer = createFragmentContainer(\r\n  SizeInfo,\r\n  graphql`\r\n    fragment SizeInfo_piece on Saleable {\r\n      dimensions {\r\n        in\r\n        cm\r\n      }\r\n      edition_of\r\n    }\r\n  `\r\n)\r\n```\r\n\r\n…and be instantiated with any type that implements the interface:\r\n\r\n```tsx\r\n<SizeInfo piece={this.props.artwork} />\r\n<SizeInfo piece={this.props.artwork.edition_sets[0]} />\r\n```"},"comment":{"url":"https://api.github.com/repos/artsy/metaphysics/issues/comments/400777304","html_url":"https://github.com/artsy/metaphysics/pull/1140#issuecomment-400777304","issue_url":"https://api.github.com/repos/artsy/metaphysics/issues/1140","id":400777304,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDc3NzMwNA==","user":{"login":"alloy","id":2320,"node_id":"MDQ6VXNlcjIzMjA=","avatar_url":"https://avatars2.githubusercontent.com/u/2320?v=4","gravatar_id":"","url":"https://api.github.com/users/alloy","html_url":"https://github.com/alloy","followers_url":"https://api.github.com/users/alloy/followers","following_url":"https://api.github.com/users/alloy/following{/other_user}","gists_url":"https://api.github.com/users/alloy/gists{/gist_id}","starred_url":"https://api.github.com/users/alloy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alloy/subscriptions","organizations_url":"https://api.github.com/users/alloy/orgs","repos_url":"https://api.github.com/users/alloy/repos","events_url":"https://api.github.com/users/alloy/events{/privacy}","received_events_url":"https://api.github.com/users/alloy/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T18:05:54Z","updated_at":"2018-06-27T18:05:54Z","author_association":"CONTRIBUTOR","body":"https://github.com/artsy/metaphysics/pull/1142"}}
{"actor":{"display_login":"alloy"}}