【发布时间】:2019-09-24 04:35:36
【问题描述】:
我需要根据第一个查询的结果在 dynamodb 上使用 aws appsync 解析器运行查询。 我有下面的用户表。 userTable
第一个查询:查找 userId=u1 且 type=user 的项目。 第二个查询:查找 userId="RefId 从第一个查询返回"且状态=完成的项目。
我需要在 appsync 解析器的一个查询中执行此操作。
#set( $expValues = {} )
#set($expression="userId = :userId ")
$!{expValues.put(":userId ", { "S" : $ctx.args.input.userId })}
#if(! $util.isNullOrEmpty($ctx.args.input.type))
#set($expression="$expression and begins_with(type)")
$!{expValues.put(":type", { "S" : $type})}
#end
{
"version" : "2018-05-29",
"operation" : "Query",
"index" : "mId_mType_index",
"scanIndexForward" : false,
"query" : {
"expression":"$expression",
#if( !${expValues.isEmpty()} )
"expressionValues" : $utils.toJson($expValues)
#end
},
#if( ${ctx.args.limit} )
"limit": ${ctx.args.limit}
#end
#if( ${ctx.args.nextToken} )
,"nextToken": "${ctx.args.nextToken}"
#end
}
【问题讨论】:
标签: amazon-web-services amazon-dynamodb graphql aws-appsync