sam-goodwin / punchcard

Type-safe AWS infrastructure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shapes aren't that fun to write.

sam-goodwin opened this issue · comments

commented

Shapes enable the generic data structures and APIs of Punchcard, but their type signatures can be excessive spaghetti.

E.g.

const table: DynamoDB.Table<"id", undefined, {
  id: StringShape;
  count: IntegerShape;
  name: StringShape;
  array: ArrayShape<StringShape>;
  struct: StructShape<...>;
  any: DynamicShape<...>;
}>

Perhaps we should look into generating Shapes from another representation, e.g. Smithy (https://github.com/awslabs/smithy) or GraphQL (https://graphql.org/, #86)?

The generated code could generate boilerplate interfaces instead of computing types with RuntimeShape<S>, resulting in more helpful (well documented) hints from the compiler/IDE toolchain. Developer experience would be just as "nice", except there would now be a new file format.

commented

Interesting code-first approach for GraphQL: https://github.com/MichalLytek/type-graphql

commented

Discussion in #86 has a lot about shapes.