MappingTemplate

class aws_cdk.aws_appsync.MappingTemplate

Bases: object

(experimental) MappingTemplates for AppSync resolvers.

Stability:

experimental

ExampleMetadata:

infused

Example:

# api: appsync.GraphqlApi
# dummy_request: appsync.MappingTemplate
# dummy_response: appsync.MappingTemplate

info = appsync.ObjectType("Info",
    definition={
        "node": appsync.ResolvableField(
            return_type=appsync.GraphqlType.string(),
            args={
                "id": appsync.GraphqlType.string()
            },
            data_source=api.add_none_data_source("none"),
            request_mapping_template=dummy_request,
            response_mapping_template=dummy_response
        )
    }
)
Stability:

experimental

Methods

abstract render_template()

(experimental) this is called to render the mapping template to a VTL string.

Stability:

experimental

Return type:

str

Static Methods

classmethod dynamo_db_delete_item(key_name, id_arg)

(experimental) Mapping template to delete a single item from a DynamoDB table.

Parameters:
  • key_name (str) – the name of the hash key field.

  • id_arg (str) – the name of the Mutation argument.

Stability:

experimental

Return type:

MappingTemplate

classmethod dynamo_db_get_item(key_name, id_arg)

(experimental) Mapping template to get a single item from a DynamoDB table.

Parameters:
  • key_name (str) – the name of the hash key field.

  • id_arg (str) – the name of the Query argument.

Stability:

experimental

Return type:

MappingTemplate

classmethod dynamo_db_put_item(key, values)

(experimental) Mapping template to save a single item to a DynamoDB table.

Parameters:
  • key (PrimaryKey) – the assigment of Mutation values to the primary key.

  • values (AttributeValues) – the assignment of Mutation values to the table attributes.

Stability:

experimental

Return type:

MappingTemplate

classmethod dynamo_db_query(cond, index_name=None)

(experimental) Mapping template to query a set of items from a DynamoDB table.

Parameters:
  • cond (KeyCondition) – the key condition for the query.

  • index_name (Optional[str]) –

Stability:

experimental

Return type:

MappingTemplate

classmethod dynamo_db_result_item()

(experimental) Mapping template for a single result item from DynamoDB.

Stability:

experimental

Return type:

MappingTemplate

classmethod dynamo_db_result_list()

(experimental) Mapping template for a result list from DynamoDB.

Stability:

experimental

Return type:

MappingTemplate

classmethod dynamo_db_scan_table()

(experimental) Mapping template to scan a DynamoDB table to fetch all entries.

Stability:

experimental

Return type:

MappingTemplate

classmethod from_file(file_name)

(experimental) Create a mapping template from the given file.

Parameters:

file_name (str) –

Stability:

experimental

Return type:

MappingTemplate

classmethod from_string(template)

(experimental) Create a mapping template from the given string.

Parameters:

template (str) –

Stability:

experimental

Return type:

MappingTemplate

classmethod lambda_request(payload=None, operation=None)

(experimental) Mapping template to invoke a Lambda function.

Parameters:
  • payload (Optional[str]) – the VTL template snippet of the payload to send to the lambda. If no payload is provided all available context fields are sent to the Lambda function

  • operation (Optional[str]) – the type of operation AppSync should perform on the data source.

Stability:

experimental

Return type:

MappingTemplate

classmethod lambda_result()

(experimental) Mapping template to return the Lambda result to the caller.

Stability:

experimental

Return type:

MappingTemplate