Closed NozomiSugiyama closed 6 years ago
AppSyncの変更完了
GraphQL schemaの変更.
listWorks(limit: Int, nextToken: ID, option: WorkQueryOption): WorkConnection
input WorkQueryOption {
tags: [String]
word: String
userId: ID
}
WorkとUserモデル共に一覧取得にバグがありそう.
AppSyncのサンプルでPaginationを行ってるので見直したが
{
"version": "2017-02-28",
"operation": "Query",
"index": "LSI-AppSyncCommentTable-by-eventId-createdAt",
"query": {
"expression": "eventId = :eventId",
"expressionValues": {
":eventId": {
"S": "$context.source.id"
}
}
},
"limit": #if($context.arguments.limit) $context.arguments.limit #else 10 #end,
"nextToken": #if($context.arguments.nextToken) "$context.arguments.nextToken" #else null #end
}
こんな感じ.
こんな記述を見つけた
// QueryRequest generates a "aws/request.Request" representing the
// client's request for the Query operation. The "output" return
// value will be populated with the request's response once the request completes
// successfuly.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
//
// See Query for more information on using the Query
// API call, and error handling.
//
// This method is useful when you want to inject custom logic or configuration
// into the SDK's request lifecycle. Such as custom headers, or retry logic.
//
//
// // Example sending a request using the QueryRequest method.
// req, resp := client.QueryRequest(params)
//
// err := req.Send()
// if err == nil { // resp is now filled
// fmt.Println(resp)
// }
//
// See also, https://docs.aws.amazon.com/goto/WebAPI/dynamodb-2012-08-10/Query
func (c *DynamoDB) QueryRequest(input *QueryInput) (req *request.Request, output *QueryOutput) {
op := &request.Operation{
Name: opQuery,
HTTPMethod: "POST",
HTTPPath: "/",
Paginator: &request.Paginator{
InputTokens: []string{"ExclusiveStartKey"},
OutputTokens: []string{"LastEvaluatedKey"},
LimitToken: "Limit",
TruncationToken: "",
},
}
if input == nil {
input = &QueryInput{}
}
output = &QueryOutput{}
req = c.newRequest(op, input, output)
return
}
Scanで行けそう
現状nextTokenの仕組みが若干違くなってしまっているのでそこの修正ができれば...
この変更は破棄
// var queryInput = &dynamodb.QueryInput{
// Limit: &limit,
// TableName: aws.String(WorkTableName),
// KeyConditions: map[string]*dynamodb.Condition{
// "id": {
// // EQ | LE | LT | GE | GT | BEGINS_WITH | BETWEEN
// // ComparisonOperator: aws.String("EQ"),
// // AttributeValueList: []*dynamodb.AttributeValue{
// // {
// // S: aws.String("7cc9ebcc-79b2-11e8-b93a-0228c0ad61bd"),
// // },
// // },
// ComparisonOperator: aws.String("NOT_NULL"),
// },
// },
// }
// if nextToken != nil {
// queryInput.ExclusiveStartKey = map[string]*dynamodb.AttributeValue{
// "id": {
// S: aws.String(*nextToken),
// },
// }
// }
// req, resp := svc.QueryRequest(queryInput)
// err := req.Send()
limit nextTokenの形はやめて、limit exclusiveStartKeyにします。
↑ AppSyncの設定完了.
同時に全ての動作確認完了
Migration to Lambda of listWorks query
Overview
検索エンジン実装のため listWorks query の構成を変更. 既存の実装であるAppSyncからResolver MappingにてDynamoDBから直接データを取得する方式から、AppSync-Resolver-Mapping-Lambdaをデータソースとするよう変更する必要がある.
Changes
AWS AppSync Resolver Mappingの変更. LambaにlistWorksの処理を追加.