captbaritone / captbaritone/grats

Support defining interfaces by extending classes

Open
#106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
358
Forks
24
PR merge metrics
No merged PRs in 30d

Description

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:

```graphql
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](https://grats.capt.dev/docs/faq/design-principles#integrate-into-the-users-existing-code), 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.