1
0

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 1 year has passed since last update.

AWS: AppSync の使い方

Last updated at Posted at 2022-02-26

DynamoDB に Query を出す AppSync の使い方です。
DynamoDB には、id, name, email という項目があるとします。

作成

「DynamoDB テーブルをインポートする」を選びます。
appsync_feb2601.png

テーブルを選びます。
appsync_feb2602.png

ロールを選びます。
appsync_feb2603.png

フィールドを追加します。
appsync_feb2604.png

API 名を入力
appsync_feb2605.png

作成したら、設定で API URL と API KEY を確認
appsync_feb2606.png

クライアントから接続

curl の例

client_curl.sh
API_URL="https://*****.appsync-api.ap-northeast-1.amazonaws.com/graphql"
#
API_KEY="da2-mfn*****"
#
curl -s -v  -XPOST -H "Content-Type:application/graphql" \
	-H "x-api-key:"${API_KEY} \
 -d '{ "query": "query {getUsers { items { id name email }}}" }' \
	${API_URL}
#

Httpie の例

client_httpie.sh
API_URL="https://*****.appsync-api.ap-northeast-1.amazonaws.com/graphql"
#
API_KEY="da2-mfn*****"
#
http POST ${API_URL} x-api-key:${API_KEY} \
        query="query {getUsers { items { id name email }}}"
#
1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?