Skip to content
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

Support defining interfaces by extending classes #106

Open
captbaritone opened this issue Jan 15, 2024 · 0 comments
Open

Support defining interfaces by extending classes #106

captbaritone opened this issue Jan 15, 2024 · 0 comments

Comments

@captbaritone
Copy link
Owner

I had originally opted not to support defining interfaces via classes because of the mismatch between TypeScript having single inheritance and GraphQL having multiple inheritance. You can't express:

type User implements Person, Node {
  # ...
}

using only class inheritance with TypeScript. That said, people do have inheritance setup in their TypeScript code bases which make sense as interfaces as they expose that same code in GraphQL. Following this design principle, we ought to support this for the cases where users have such code.

There will be some challenges:

  1. How do we figure out from TypeScript which classes extend which other classes. Note that we need to include transitive cases. This may impact our incremental compilation strategy.
  2. We need to figure out how overrides work and ensure their ordering is applied correctly. If the concrete class and extended class both implement a field, which one wins? With multiple inheritance this gets tricky.
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