たれぱんのびぼーろく

わたしの備忘録、生物学とプログラミングが多いかも

GraphQL Transform

GraphQL Transform
directivesを含むGraphQL schema (GraphQL SDL) から、backend provisioning code (CloudFormation Templates) を生成する仕組み.
Amplify cli内に存在する仕組み.

利用するdirectives/backendによって処理は色々。custom transformも可能.
datastoreを使うならDynamoDB + AppSync_server + AppSync_resolverが必要.

you define your application’s data model using the GraphQL Schema Definition Language (SDL) and the library handles converting your SDL definition into a set of fully descriptive AWS CloudFormation templates that implement your data model.

data model

@model: DynamoDB item化 + Resolver設定
@key: DynamoDB key設定(primary key, secondary index key)

data model分のschema書くだけでschemaの他の部分も生成してくれる.

resolverも書くし、resolverでfrontend codeも決まってくるんだけど、frontend code生成は誰がしてるの?
frontend code生成っていうのが曖昧.

GQL Transformって複数の@model時にTableいくつ作るの? 複数Table? 単一ならPK/SK不一致時の振る舞いは?

既存のGraphQL Transform + Amplify cliは自由度が最大化されていない(詳細を隠す哲学の模様)
内部的にはCFn Templatesを直接生成しているみたいだけど、AWS CDKで書いてあればこちらからhookできてよさそうなものだが、内部はとても複雑で何回かチャレンジしたけど改造できるめどは立たなかった.