0

Schema snippet:

type Query {
  getPCSData(country: $String, year: $String, payCycle: $String): PCSDataOutput
}

Dynamodb Resolver:

 PCSDataResolver:
 Type: AWS::AppSync::Resolver
 DependsOn: PCSGraphQLSchema
 Properties:
   ApiId:
     Fn::GetAtt: [PCSGraphQLApi, ApiId]
TypeName: Query
FieldName: getPCSData
DataSourceName:
  Fn::GetAtt: [PCSGraphQLDDBDataSource, Name]
RequestMappingTemplate: |
   {
       "version": "2017-02-28",
       "operation": "GetItem",
       "key": {
        "Country_Year_PayCycle": ?????????
        }
   }
ResponseMappingTemplate: "$util.toJson($ctx.result)"

Here, I am looking to form key Country_Year_PayCycle using all three arguments passed from the query something like this Country_Year_PayCycle = country+ year+payCycle

Is it possible to concat the query arguments and form key ?

Dev Kumar
  • 93
  • 7

1 Answers1

0

This is how I resolve

RequestMappingTemplate: |
## Set up some space to keep track of things we're updating **
#set($concat ="_")
#set($country = $ctx.args.country )
#set($year = $ctx.args.year )
#set($payCycle = $ctx.args.payCycle )
#set($pk = "$country$concat$year$concat$payCycle")

{
    "version": "2017-02-28",
    "operation": "GetItem",
    "key": {
        "Country_Year_PayCycle": $util.dynamodb.toDynamoDBJson($pk)
    }
}
Dev Kumar
  • 93
  • 7