class MappingTemplate
| Language | Type name | 
|---|---|
|  .NET | Amazon.CDK.AWS.AppSync.MappingTemplate | 
|  Java | software.amazon.awscdk.services.appsync.MappingTemplate | 
|  Python | aws_cdk.aws_appsync.MappingTemplate | 
|  TypeScript (source) | @aws-cdk/aws-appsyncยปMappingTemplate | 
MappingTemplates for AppSync resolvers.
Example
declare const api: appsync.GraphqlApi;
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const info = new appsync.ObjectType('Info', {
  definition: {
    node: new appsync.ResolvableField({
      returnType: appsync.GraphqlType.string(),
      args: {
        id: appsync.GraphqlType.string(),
      },
      dataSource: api.addNoneDataSource('none'),
      requestMappingTemplate: dummyRequest,
      responseMappingTemplate: dummyResponse,
    }),
  },
});
Initializer
new MappingTemplate()
Methods
| Name | Description | 
|---|---|
| render | this is called to render the mapping template to a VTL string. | 
| static dynamo | Mapping template to delete a single item from a DynamoDB table. | 
| static dynamo | Mapping template to get a single item from a DynamoDB table. | 
| static dynamo | Mapping template to save a single item to a DynamoDB table. | 
| static dynamo | Mapping template to query a set of items from a DynamoDB table. | 
| static dynamo | Mapping template for a single result item from DynamoDB. | 
| static dynamo | Mapping template for a result list from DynamoDB. | 
| static dynamo | Mapping template to scan a DynamoDB table to fetch all entries. | 
| static from | Create a mapping template from the given file. | 
| static from | Create a mapping template from the given string. | 
| static lambda | Mapping template to invoke a Lambda function. | 
| static lambda | Mapping template to return the Lambda result to the caller. | 
renderTemplate() 
public renderTemplate(): string
Returns
- string
this is called to render the mapping template to a VTL string.
static dynamoDbDeleteItem(keyName, idArg)   
public static dynamoDbDeleteItem(keyName: string, idArg: string): MappingTemplate
Parameters
- keyName stringโ the name of the hash key field.
- idArg stringโ the name of the Mutation argument.
Returns
Mapping template to delete a single item from a DynamoDB table.
static dynamoDbGetItem(keyName, idArg)   
public static dynamoDbGetItem(keyName: string, idArg: string): MappingTemplate
Parameters
- keyName stringโ the name of the hash key field.
- idArg stringโ the name of the Query argument.
Returns
Mapping template to get a single item from a DynamoDB table.
static dynamoDbPutItem(key, values)   
public static dynamoDbPutItem(key: PrimaryKey, values: AttributeValues): MappingTemplate
Parameters
- key Primaryโ the assigment of Mutation values to the primary key.Key 
- values Attributeโ the assignment of Mutation values to the table attributes.Values 
Returns
Mapping template to save a single item to a DynamoDB table.
static dynamoDbQuery(cond, indexName?)  
public static dynamoDbQuery(cond: KeyCondition, indexName?: string): MappingTemplate
Parameters
- cond Keyโ the key condition for the query.Condition 
- indexName string
Returns
Mapping template to query a set of items from a DynamoDB table.
static dynamoDbResultItem()   
public static dynamoDbResultItem(): MappingTemplate
Returns
Mapping template for a single result item from DynamoDB.
static dynamoDbResultList()   
public static dynamoDbResultList(): MappingTemplate
Returns
Mapping template for a result list from DynamoDB.
static dynamoDbScanTable()   
public static dynamoDbScanTable(): MappingTemplate
Returns
Mapping template to scan a DynamoDB table to fetch all entries.
static fromFile(fileName) 
public static fromFile(fileName: string): MappingTemplate
Parameters
- fileName string
Returns
Create a mapping template from the given file.
static fromString(template) 
public static fromString(template: string): MappingTemplate
Parameters
- template string
Returns
Create a mapping template from the given string.
static lambdaRequest(payload?, operation?) 
public static lambdaRequest(payload?: string, operation?: string): MappingTemplate
Parameters
- payload stringโ the VTL template snippet of the payload to send to the lambda.
- operation stringโ the type of operation AppSync should perform on the data source.
Returns
Mapping template to invoke a Lambda function.
static lambdaResult() 
public static lambdaResult(): MappingTemplate
Returns
Mapping template to return the Lambda result to the caller.
