コミートム合同会社

コミートム合同会社

AppSyncのリゾルバをAmplifyで修正する

Amplify AppSync 1. amplifybackendapi AppSync buildresolvers2. amplifybackendapi AppSync resolvers3. 4. amplify Push5. AppSync This article explains how to fix AppSync resolver with Amplify. The steps are as follows1. Find the automatically generated resolvers in the project folderamplifybackendapicreated AppSync namebuildresolvers folder.2. Copy the resolver you want to modify and paste it in the project folderamplifybackendapicreated AppSync nameresolvers folder.3. Make your changes to the resolver.4. Run amplify push to update the resolver.5. Check the modification from the AppSync console.
by JanitorAug 27, 2023

Jump Links

1.自動で生成されるリゾルバの場所
2.修正したいリゾルバを移動
3.リゾルバの修正
4.amplify push
5.おわりに
AppSyncのリゾルバをAmplifyで修正する方法(VTL)です。Amplifyで作成したAppSyncであれば、リゾルバが記載されたファイルがbackendフォルダ内にできていますので、VSCodeなどで修正がしやすいです。ごくまれに修正することがありそうなので、備忘録として記載します。
AppSyncのリゾルバをAmplifyで修正する方法(VTL)です。Amplifyで作成したAppSyncであれば、リゾルバが記載されたファイルがbackendフォルダ内にできていますので、VSCodeなどで修正がしやすいです。ごくまれに修正することがありそうなので、備忘録として記載します。
1.自動で生成されるリゾルバの場所
1.自動で生成されるリゾルバの場所
自動で生成されるリゾルバの場所は、「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/build/resolvers」にあります。
自動で生成されるリゾルバの場所は、「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/build/resolvers」にあります。
2.修正したいリゾルバを移動
2.修正したいリゾルバを移動
上記フォルダ内の修正したいリゾルバのファイルを「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/resolvers」にコピペします。
上記フォルダ内の修正したいリゾルバのファイルを「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/resolvers」にコピペします。
3.リゾルバの修正
3.リゾルバの修正
今回はリゾルバにコメントを入れています。2行目に「## resolver modify test」というコメントを入れました。Cognitoの認証を入れていらっしゃる方はリゾルバファイルを開いてみるとわかるかと思いますが、ユーザに割り当てられるユーザの識別子やユーザのグループ名は、下記の通り取得ができるようです。
今回はリゾルバにコメントを入れています。2行目に「## resolver modify test」というコメントを入れました。Cognitoの認証を入れていらっしゃる方はリゾルバファイルを開いてみるとわかるかと思いますが、ユーザに割り当てられるユーザの識別子やユーザのグループ名は、下記の通り取得ができるようです。
ユーザ識別子の取得 $ctx.identity.claims.get("sub") グループ $ctx.identity.claims.get("cognito:groups")
ユーザ識別子の取得 $ctx.identity.claims.get("sub") グループ $ctx.identity.claims.get("cognito:groups")
4.amplify push
4.amplify push
amplify pushして更新が完了です。build内のリゾルバも上書きされ、AppSyncのコンソールからも、作成したAppSync名称 -> 関数で該当するリゾルバの名前をクリックすると修正が確認できます。
amplify pushして更新が完了です。build内のリゾルバも上書きされ、AppSyncのコンソールからも、作成したAppSync名称 -> 関数で該当するリゾルバの名前をクリックすると修正が確認できます。
5.おわりに
5.おわりに
javascriptでもリゾルバを編集することができるようです。
javascriptでもリゾルバを編集することができるようです。

Editors pick

Our other articles

AppSyncのリゾルバをAmplifyで修正する

Amplify AppSync 1. amplifybackendapi AppSync buildresolvers2. amplifybackendapi AppSync resolvers3. 4. amplify Push5. AppSync This article explains how to fix AppSync resolver with Amplify. The steps are as follows1. Find the automatically generated resolvers in the project folderamplifybackendapicreated AppSync namebuildresolvers folder.2. Copy the resolver you want to modify and paste it in the project folderamplifybackendapicreated AppSync nameresolvers folder.3. Make your changes to the resolver.4. Run amplify push to update the resolver.5. Check the modification from the AppSync console.
by JanitorAug 27, 2023

Jump Links

1.自動で生成されるリゾルバの場所
2.修正したいリゾルバを移動
3.リゾルバの修正
4.amplify push
5.おわりに
AppSyncのリゾルバをAmplifyで修正する方法(VTL)です。Amplifyで作成したAppSyncであれば、リゾルバが記載されたファイルがbackendフォルダ内にできていますので、VSCodeなどで修正がしやすいです。ごくまれに修正することがありそうなので、備忘録として記載します。
AppSyncのリゾルバをAmplifyで修正する方法(VTL)です。Amplifyで作成したAppSyncであれば、リゾルバが記載されたファイルがbackendフォルダ内にできていますので、VSCodeなどで修正がしやすいです。ごくまれに修正することがありそうなので、備忘録として記載します。
1.自動で生成されるリゾルバの場所
1.自動で生成されるリゾルバの場所
自動で生成されるリゾルバの場所は、「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/build/resolvers」にあります。
自動で生成されるリゾルバの場所は、「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/build/resolvers」にあります。
2.修正したいリゾルバを移動
2.修正したいリゾルバを移動
上記フォルダ内の修正したいリゾルバのファイルを「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/resolvers」にコピペします。
上記フォルダ内の修正したいリゾルバのファイルを「プロジェクトフォルダ/amplify/backend/api/作成したAppSync名称/resolvers」にコピペします。
3.リゾルバの修正
3.リゾルバの修正
今回はリゾルバにコメントを入れています。2行目に「## resolver modify test」というコメントを入れました。Cognitoの認証を入れていらっしゃる方はリゾルバファイルを開いてみるとわかるかと思いますが、ユーザに割り当てられるユーザの識別子やユーザのグループ名は、下記の通り取得ができるようです。
今回はリゾルバにコメントを入れています。2行目に「## resolver modify test」というコメントを入れました。Cognitoの認証を入れていらっしゃる方はリゾルバファイルを開いてみるとわかるかと思いますが、ユーザに割り当てられるユーザの識別子やユーザのグループ名は、下記の通り取得ができるようです。
ユーザ識別子の取得 $ctx.identity.claims.get("sub") グループ $ctx.identity.claims.get("cognito:groups")
ユーザ識別子の取得 $ctx.identity.claims.get("sub") グループ $ctx.identity.claims.get("cognito:groups")
4.amplify push
4.amplify push
amplify pushして更新が完了です。build内のリゾルバも上書きされ、AppSyncのコンソールからも、作成したAppSync名称 -> 関数で該当するリゾルバの名前をクリックすると修正が確認できます。
amplify pushして更新が完了です。build内のリゾルバも上書きされ、AppSyncのコンソールからも、作成したAppSync名称 -> 関数で該当するリゾルバの名前をクリックすると修正が確認できます。
5.おわりに
5.おわりに
javascriptでもリゾルバを編集することができるようです。
javascriptでもリゾルバを編集することができるようです。

Editors pick

Our other articles
© 2023 - Comytom LLC