1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AWS Amplify のビルドで『The input value type 'AuthRule' is not present when resolving type 'AMPLIFY'』が発生した際の対応

Posted at

AWSの発表しているAmplify + Reactで簡単なアプリケーションをデプロイするというチュートリアルをやっていたところ、表題の問題に遭遇。

ローカルでの動作は問題なくGraphQLを使ったデータ登録ができたものの、その変更をpushし、amplifyにデプロイしようとしたところで以下のようなエラーが出てビルドに失敗した。

AWS_Amplify_Console.png

CloudFormation上では以下のようなログ
CloudFormation_-_スタック_amplify-amplifyreact-master-144648-apiamplifyreact-5V93MRL0X15Y.png

The input value type 'AuthRule' is not present when resolving type 'AMPLIFY'

AuthRule に問題があるとのことなので、ソースコード内を検索して引っかかったのが以下の箇所。
amplify add apiで自動作成されるGraphQLのスキーマ定義ファイルですね。
コードの意味はよくわからないけど FOR TESTING ONLY! と付いているのが怪しい感じ。

amplify/backend/api/amplifyreact/schema.graphql

# This "input" configures a global authorization rule to enable public access to
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
input AMPLIFY { globalAuthRule: AuthRule = { allow: public } } # FOR TESTING ONLY!

type Note @model {
  id: ID!
  name: String!
  description: String
}

冒頭のコメントにあるURLに詳しい説明があるとのことなので見てみると。

To help you get started, there's a global authorization rule defined when you create a new GraphQL schema. 
For production environments, remove the global authorization rule and apply rules on each model instead.

開発用にcreate, update, delete権限を全スキーマに付与してくれる設定みたい。
まずはこの設定で開発を初めて後から権限を絞ってね的な話なのかな。

ともあれ、本番環境ではこの設定は消すようにとのことなので以下のように変更。
(このチュートリアルでは認証機能が既に実装されているので、認証されたユーザーのみ許可する、という設定のほうが正しいのだけど、まずはビルドエラーを解決したかったので { allow: public }にしてます。。)

# input AMPLIFY { globalAuthRule: AuthRule = { allow: public } } # FOR TESTING ONLY!

type Note @model @auth(rules: [{ allow: public }]) {
  id: ID!
  name: String!
  description: String
}

変更をGithubにpushして再度ビルドを走らせると無事ビルドが成功しました。

AWS_Amplify_Console.png

React_App.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?