Class MappingTemplate

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.appsync.MappingTemplate
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.95.0 (build f1ff514)", date="2024-03-26T18:09:19.808Z") @Stability(Stable) public abstract class MappingTemplate extends software.amazon.jsii.JsiiObject
MappingTemplates for AppSync resolvers.

Example:

 import software.amazon.awscdk.services.events.*;
 GraphqlApi api = GraphqlApi.Builder.create(this, "EventBridgeApi")
         .name("EventBridgeApi")
         .definition(Definition.fromFile(join(__dirname, "appsync.eventbridge.graphql")))
         .build();
 EventBus bus = EventBus.Builder.create(this, "DestinationEventBus").build();
 EventBridgeDataSource dataSource = api.addEventBridgeDataSource("NoneDS", bus);
 dataSource.createResolver("EventResolver", BaseResolverProps.builder()
         .typeName("Mutation")
         .fieldName("emitEvent")
         .requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
         .responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
         .build());
 
  • Constructor Details

    • MappingTemplate

      protected MappingTemplate(software.amazon.jsii.JsiiObjectRef objRef)
    • MappingTemplate

      protected MappingTemplate(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • MappingTemplate

      @Stability(Stable) protected MappingTemplate()
  • Method Details

    • dynamoDbDeleteItem

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbDeleteItem(@NotNull String keyName, @NotNull String idArg)
      Mapping template to delete a single item from a DynamoDB table.

      Parameters:
      keyName - the name of the hash key field. This parameter is required.
      idArg - the name of the Mutation argument. This parameter is required.
    • dynamoDbGetItem

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbGetItem(@NotNull String keyName, @NotNull String idArg, @Nullable Boolean consistentRead)
      Mapping template to get a single item from a DynamoDB table.

      Parameters:
      keyName - the name of the hash key field. This parameter is required.
      idArg - the name of the Query argument. This parameter is required.
      consistentRead -
    • dynamoDbGetItem

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbGetItem(@NotNull String keyName, @NotNull String idArg)
      Mapping template to get a single item from a DynamoDB table.

      Parameters:
      keyName - the name of the hash key field. This parameter is required.
      idArg - the name of the Query argument. This parameter is required.
    • dynamoDbPutItem

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbPutItem(@NotNull PrimaryKey key, @NotNull AttributeValues values)
      Mapping template to save a single item to a DynamoDB table.

      Parameters:
      key - the assigment of Mutation values to the primary key. This parameter is required.
      values - the assignment of Mutation values to the table attributes. This parameter is required.
    • dynamoDbQuery

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbQuery(@NotNull KeyCondition cond, @Nullable String indexName, @Nullable Boolean consistentRead)
      Mapping template to query a set of items from a DynamoDB table.

      Parameters:
      cond - the key condition for the query. This parameter is required.
      indexName -
      consistentRead -
    • dynamoDbQuery

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbQuery(@NotNull KeyCondition cond, @Nullable String indexName)
      Mapping template to query a set of items from a DynamoDB table.

      Parameters:
      cond - the key condition for the query. This parameter is required.
      indexName -
    • dynamoDbQuery

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbQuery(@NotNull KeyCondition cond)
      Mapping template to query a set of items from a DynamoDB table.

      Parameters:
      cond - the key condition for the query. This parameter is required.
    • dynamoDbResultItem

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbResultItem()
      Mapping template for a single result item from DynamoDB.
    • dynamoDbResultList

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbResultList()
      Mapping template for a result list from DynamoDB.
    • dynamoDbScanTable

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbScanTable(@Nullable Boolean consistentRead)
      Mapping template to scan a DynamoDB table to fetch all entries.

      Parameters:
      consistentRead -
    • dynamoDbScanTable

      @Stability(Stable) @NotNull public static MappingTemplate dynamoDbScanTable()
      Mapping template to scan a DynamoDB table to fetch all entries.
    • fromFile

      @Stability(Stable) @NotNull public static MappingTemplate fromFile(@NotNull String fileName)
      Create a mapping template from the given file.

      Parameters:
      fileName - This parameter is required.
    • fromString

      @Stability(Stable) @NotNull public static MappingTemplate fromString(@NotNull String template)
      Create a mapping template from the given string.

      Parameters:
      template - This parameter is required.
    • lambdaRequest

      @Stability(Stable) @NotNull public static MappingTemplate lambdaRequest(@Nullable String payload, @Nullable String operation)
      Mapping template to invoke a Lambda function.

      Parameters:
      payload - the VTL template snippet of the payload to send to the lambda.
      operation - the type of operation AppSync should perform on the data source.
    • lambdaRequest

      @Stability(Stable) @NotNull public static MappingTemplate lambdaRequest(@Nullable String payload)
      Mapping template to invoke a Lambda function.

      Parameters:
      payload - the VTL template snippet of the payload to send to the lambda.
    • lambdaRequest

      @Stability(Stable) @NotNull public static MappingTemplate lambdaRequest()
      Mapping template to invoke a Lambda function.
    • lambdaResult

      @Stability(Stable) @NotNull public static MappingTemplate lambdaResult()
      Mapping template to return the Lambda result to the caller.
    • renderTemplate

      @Stability(Stable) @NotNull public abstract String renderTemplate()
      this is called to render the mapping template to a VTL string.