sam-goodwin / punchcard

Type-safe AWS infrastructure.
Apache License 2.0
507 stars 20 forks source link

Shapes aren't that fun to write. #87

Closed sam-goodwin closed 4 years ago

sam-goodwin commented 4 years ago

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/, https://github.com/punchcard/punchcard/issues/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.

sam-goodwin commented 4 years ago

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

sam-goodwin commented 4 years ago

Discussion in https://github.com/punchcard/punchcard/issues/86 has a lot about shapes.