captbaritone / grats

Implementation-First GraphQL for TypeScript
https://grats.capt.dev
MIT License
309 stars 16 forks source link

Make classes and interfaces inherit GraphQL fields and interfaces from classes they extend and interfaces they implement #145

Open captbaritone opened 4 months ago

captbaritone commented 4 months ago
/** @gqlType */
class Parent {
  /** @gqlField */
  parentField: string;
}

class Intermediate extends Parent {}

/** @gqlType */
export class Child extends Intermediate {
  /** @gqlField */
  childField: string;
}

Would now extract:

type Child {
  childField: String
  parentField: String
}

type Parent {
  parentField: String
}

This change also allows you to define GraphQL interfaces using TypeScript types.

TODO

netlify[bot] commented 4 months ago

Deploy Preview for grats failed.

Name Link
Latest commit 5c7c0ae0942c9fd288fc82a8e51e65b94b3fd0c2
Latest deploy log https://app.netlify.com/sites/grats/deploys/66c57abbb652600008d4ab72
captbaritone commented 4 months ago

This feature has made me realize I want Grats to be more about trying to derive GraphQL matching the semantics of idiomatic TypeScript code where possible.

So, our goal here should be to match the semantics of TypeScript. One way to view a /** @gqlField */ annotation is as making that field more specific. In typing parlance, an annotated field is a subtype of an unannotated field. What would that mean:

Nice properties:

Challenges