【问题标题】:Nested query using appsync resolver, aws dymaodb使用 appsync 解析器、aws dymaodb 的嵌套查询
【发布时间】: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


    【解决方案1】:

    您可以使用 AWS AppSync 中的管道求解器来执行此操作。管道解析器可以有多个解析器函数,它们可以有自己的数据源。管道中的下一个函数可以使用前一个解析器的结果。

    我需要在 appsync 解析器的一个查询中执行此操作。

    我不知道你为什么(认为)你需要这个,但这是不可能的。

    【讨论】:

      猜你喜欢
      • 2019-02-04
      • 2020-02-12
      • 2018-12-22
      • 2019-01-19
      • 2021-04-21
      • 2018-10-11
      • 2019-09-12
      • 2019-10-14
      • 2019-07-03
      相关资源
      最近更新 更多