[AWS AppSync] Schema Creation Status is FAILED with details: Internal Failure while saving the schema.
今回は CloudFormation あるあるのエラーメッセージが抽象的でエラーの特定に難航するけど、よくみたら大したこと無いシリーズです。
🔥 事象
AWS AppSync を利用していて、以下のような GraphQL をデプロイすると表題のエラーが発生してデプロイ失敗しました。
CloudFormation では表題のエラーが発生していました。
エラーメッセージと schema.graphql
を見ても何が悪いかさっぱりでした。
input UpdatePlayerInput { name: String! salary: Int! } input UpdateTeamInput { name: String player: [Player!] } type Player { name: String! salary: Int! } type Team { id: ID! name: String player: [Player!] }
💡 原因
当たり前ですが、type では type を設定し、input では input を設定する必要がありました。
今回の場合は Team
の player は Player
を設定し、UpdateTeamInput
の player は UpdatePlayerInput
を設定します。
input UpdatePlayerInput { name: String! salary: Int! } input UpdateTeamInput { name: String player: [UpdatePlayerInput!] } type Player { name: String! salary: Int! } type Team { id: ID! name: String player: [Player!] }
デプロイしたときのエラーメッセージが不親切で原因解明に時間がかかってしまいましたが、こんな当たり前のことだったんですね!
ちなみに
AWS AppSync Console 画面で graphql を入力するとリアルタイムでバリデーションしてくれるぞ!👍
NG
Expected [Player!] to be a GraphQL input type.
この気の利いたエラーメッセージを CloudFormation に出してくれませんかね…。
OK
まとめ
ということで、GraphQL の静的チェックできていれば Schema Creation Status is FAILED
は発生しない(はず)。
AWS AppSync Console 画面が便利なことがわかりましたが、いちいちコンソール開かずにチェックできるよう VS Code Extension でなんかいいのないですかね〜。