Skip to content

Proposal: Add Interface inheritance for definitions #970

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

Closed
SerafimArts opened this issue Jul 26, 2017 · 1 comment
Closed

Proposal: Add Interface inheritance for definitions #970

SerafimArts opened this issue Jul 26, 2017 · 1 comment

Comments

@SerafimArts
Copy link

SerafimArts commented Jul 26, 2017

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

interface Creatable {
    createdAt: String!
}

interface Updatable {
    updatedAt: String
}

Variation of implementation

interface Person extends Creatable, Updatable {
    id: ID!
    name: String!
    # ...
}

class User implements Person {
    # Impl of interface fields: 'id', 'name', 'createdAt', 'updatedAt'
}

Interface fields overriding

Discussion needed. I think. e.g. how to consider the LSP (Liskov Substitution Principle)?

  1. Allows NonNull for Nullable fields?
  2. Allows ListType for "Single" type def?
  3. Allow to increase/decrease the number of arguments for field input?
# Example
interface HasDates extends Creatable, Updatable {
    updatedAt: String! # Overriding nullable field
}

Errors

  1. Error while cyclic inheritance
interface A extends B { ... }
interface B extends A { ... }
  1. Error inheritance twice
interface Person extends Creatable, Updatable { ... }

type User implements Person, Creatable {
    # Error: Can not implement "Creatable" interface. Interface already defined in Person.
}

Like everything foreseen, there are ideas? =)

@SerafimArts
Copy link
Author

SerafimArts commented Aug 3, 2017

I think that this proposal should be moved here graphql/graphql-spec#335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant