{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/graphql/issues/295","repository_url":"https://api.github.com/repos/facebook/graphql","labels_url":"https://api.github.com/repos/facebook/graphql/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/facebook/graphql/issues/295/comments","events_url":"https://api.github.com/repos/facebook/graphql/issues/295/events","html_url":"https://github.com/facebook/graphql/issues/295","id":219053027,"number":295,"title":"Proposal: Allow interfaces to implement other interfaces","user":{"login":"mike-marcacci","id":690517,"avatar_url":"https://avatars1.githubusercontent.com/u/690517?v=4","gravatar_id":"","url":"https://api.github.com/users/mike-marcacci","html_url":"https://github.com/mike-marcacci","followers_url":"https://api.github.com/users/mike-marcacci/followers","following_url":"https://api.github.com/users/mike-marcacci/following{/other_user}","gists_url":"https://api.github.com/users/mike-marcacci/gists{/gist_id}","starred_url":"https://api.github.com/users/mike-marcacci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mike-marcacci/subscriptions","organizations_url":"https://api.github.com/users/mike-marcacci/orgs","repos_url":"https://api.github.com/users/mike-marcacci/repos","events_url":"https://api.github.com/users/mike-marcacci/events{/privacy}","received_events_url":"https://api.github.com/users/mike-marcacci/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-04-03T20:32:31Z","updated_at":"2017-10-27T03:11:59Z","closed_at":null,"author_association":"NONE","body":"This proposal expands upon the ideas described in #294 (which ended up already being implemented).\r\n\r\nI'd like to suggest that GraphQL be expanded to allow an `interface` to `implement` another interface. This would allow for higher order interfaces and open the door for frameworks and tooling to describe their requirements in GraphQL, which would be implemented in userland interfaces and types.\r\n\r\nHere's a (very contrived) example borrowed from #294 and expanded upon to show how hierarchies would exist:\r\n\r\n\r\n```graphql\r\ninterface Pet {\r\n\tid: !ID\r\n\tsex: Sex\r\n\tname: String\r\n\tmother: Pet\r\n\tfather: Pet\r\n}\r\n\r\ninterface Equine implements Pet {\r\n\tid: !ID\r\n\tsex: Sex\r\n\tname: String\r\n\tmother: Pet\r\n\tfather: Pet\r\n\thands: Float\r\n}\r\n\r\ntype Horse implements Equine {\r\n\tid: !ID\r\n\tsex: Sex\r\n\tname: String\r\n\tmother: Horse\r\n\tfather: Horse\r\n\thands: Float\r\n}\r\n\r\ntype Donkey implements Equine {\r\n\tid: !ID\r\n\tsex: Sex\r\n\tname: String\r\n\tmother: Donkey\r\n\tfather: Donkey\r\n\thands: Float\r\n}\r\n\r\ntype Mule implements Equine {\r\n\tid: !ID\r\n\tsex: Sex\r\n\tname: String\r\n\tmother: Equine\r\n\tfather: Equine\r\n\thands: Float\r\n}\r\n```\r\n\r\nWhat's important here is that in a context where we generically have `Pet`s, each pet's `father` is only guaranteed to be a `Pet`. When we know we have a `Mule`, though, we know that its father is an `Equine`.\r\n\r\nWith these two features, tools which currently depend on schema *conventions* (like the Relay specs) could codify their requirements with GraphQL.\r\n\r\n### A Real-World Case\r\n\r\nI have been working on a system which allows offline, concurrent modifications to versioned documents. The problem and solution are very generic, but the current state of the GraphQL type system doesn't allow me to describe these general-purpose shapes. Much like the Relay team had to define a convention for any type ending in `Connection`, I have an internal spec describing any type with a name ending in `Object`, `Entity`, and `Change`. So, for example, I have a `HikeObject`, `HikeEntity`, and `HikeChange`; I also have a `ClimbObject`, `ClimbEntity`, and `ClimbChange`.\r\n\r\nI've found myself wishing I could use the GraphQL type system to describe these requirements, and because the current spec is *so close*, I find myself thinking of the schema in these terms.\r\n\r\nThis would make that possible, and bring GraphQL's type safety to tools that solve generic problems with GraphQL."},"comment":{"url":"https://api.github.com/repos/facebook/graphql/issues/comments/339860816","html_url":"https://github.com/facebook/graphql/issues/295#issuecomment-339860816","issue_url":"https://api.github.com/repos/facebook/graphql/issues/295","id":339860816,"user":{"login":"MatthewHerbst","id":1287375,"avatar_url":"https://avatars2.githubusercontent.com/u/1287375?v=4","gravatar_id":"","url":"https://api.github.com/users/MatthewHerbst","html_url":"https://github.com/MatthewHerbst","followers_url":"https://api.github.com/users/MatthewHerbst/followers","following_url":"https://api.github.com/users/MatthewHerbst/following{/other_user}","gists_url":"https://api.github.com/users/MatthewHerbst/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewHerbst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewHerbst/subscriptions","organizations_url":"https://api.github.com/users/MatthewHerbst/orgs","repos_url":"https://api.github.com/users/MatthewHerbst/repos","events_url":"https://api.github.com/users/MatthewHerbst/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewHerbst/received_events","type":"User","site_admin":false},"created_at":"2017-10-27T03:11:59Z","updated_at":"2017-10-27T03:11:59Z","author_association":"NONE","body":"While this is being discussed, does anyone have a clean workaround that they are using?"}}
{"actor":{"display_login":"MatthewHerbst"}}