-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Add Interface inheritance for definitions #335
Comments
Ooops... It seems like a duplication of #295 |
It's similar but not related. Inheritance implies that the parent interface's fields are implicitly included in the child interface's schema. Additionally, you've touched on the topic of multiple inheritance and overriding properties of inherited fields. Neither of these are proposed in #295. I think that it's fair to say that this is different enough to not be a duplicate. However, the proposals conflict (in that they accomplish similar goals in different ways) and thus should be considered as mutually exclusive. |
@tylercrompton Convincingly, I'll reopen ann issue =) However, I note that interfaces just exist to solve the problem of multiple inheritance and attach this link here: https://en.wikipedia.org/wiki/Interface_segregation_principle At the moment the interfaces are a rudiment without the corresponding functionality. |
I think that for the sake of development and transition, we should consider deferring multiple inheritance and possibly "strictification" of types as well to a separate issue, pending the adoption of the simplified version of your proposal. In other words, I think that this proposal should focus solely on regular inheritance (for now) for the sake of getting at least something workable approved. Additionally, your proposal introduces the diamond inheritance problem since types can implement multiple interfaces. We need to address this by identifying the desired mitigation algorithm. |
So according to this issue, it seems that implicit inheritance is still not supported? Is it strictly necessary to declare all the fields when implementing an interface? There is no extension / polymorphic mechanism with implicit field inheritance in graph? |
@Recio You can use custom directives to implement this behavior. This is exactly what I did: directive @extends(type: String!) on OBJECT
type Some { ... }
type Some2 @extends(type: "Some") { ... } But I had to get inside the building pipeline to implement the logic of these directives. |
@SerafimArts I'm a bit of a newb on the matter, but I suppose on build you inject the code from Some into Some2 ? |
@Recio in my case everything is different. I do not know how it works in the JS, because I implement my own SDL compiler =) |
See: #500 (comment) TL;DR this proposal doesn't allow new use cases that were not already possible and degrades readability of schema in the name of writing less, which goes against GraphQL's guiding principles |
Spec (http://facebook.github.io/graphql/#sec-Interfaces) does not proposes this feature. But this is will be good for ISP (Interface Segregation Principle) as example.
Example:
Base definitions
Variation of implementation
Interface fields overriding
Discussion needed. I think. e.g. how to consider the LSP (Liskov Substitution Principle)?
Errors
Like everything foreseen, there are ideas? =)
The text was updated successfully, but these errors were encountered: