EvaluateMappingTemplate - AWS AppSync

EvaluateMappingTemplate

Evaluates a given template and returns the response. The mapping template can be a request or response template.

Request templates take the incoming request after a GraphQL operation is parsed and convert it into a request configuration for the selected data source operation. Response templates interpret responses from the data source and map it to the shape of the GraphQL field output type.

Mapping templates are written in the Apache Velocity Template Language (VTL).

Request Syntax

POST /dataplane-evaluatetemplate HTTP/1.1 Content-type: application/json { "context": "string", "template": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

context

The map that holds all of the contextual information for your resolver invocation. A context is required for this action.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 28000.

Pattern: ^[\s\S]*$

Required: Yes

template

The mapping template; this can be a request or response template. A template is required for this action.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 65536.

Pattern: ^[\s\S]*$

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "error": { "message": "string" }, "evaluationResult": "string", "logs": [ "string" ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

error

The ErrorDetail object.

Type: ErrorDetail object

evaluationResult

The mapping template; this can be a request or response template.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 65536.

Pattern: ^[\s\S]*$

logs

A list of logs that were generated by calls to util.log.info and util.log.error in the evaluated code.

Type: Array of strings

Errors

For information about the errors that are common to all actions, see Common Errors.

AccessDeniedException

You don't have access to perform this operation on this resource.

HTTP Status Code: 403

BadRequestException

The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.

HTTP Status Code: 400

InternalFailureException

An internal AWS AppSync error occurred. Try your request again.

HTTP Status Code: 500

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: