

# EvaluateMappingTemplate
<a name="API_EvaluateMappingTemplate"></a>

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
<a name="API_EvaluateMappingTemplate_RequestSyntax"></a>

```
POST /v1/dataplane-evaluatetemplate HTTP/1.1
Content-type: application/json

{
   "context": "string",
   "template": "string"
}
```

## URI Request Parameters
<a name="API_EvaluateMappingTemplate_RequestParameters"></a>

The request does not use any URI parameters.

## Request Body
<a name="API_EvaluateMappingTemplate_RequestBody"></a>

The request accepts the following data in JSON format.

 ** [context](#API_EvaluateMappingTemplate_RequestSyntax) **   <a name="appsync-EvaluateMappingTemplate-request-context"></a>
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](#API_EvaluateMappingTemplate_RequestSyntax) **   <a name="appsync-EvaluateMappingTemplate-request-template"></a>
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
<a name="API_EvaluateMappingTemplate_ResponseSyntax"></a>

```
HTTP/1.1 200
Content-type: application/json

{
   "error": { 
      "message": "string"
   },
   "evaluationResult": "string",
   "logs": [ "string" ],
   "outErrors": "string",
   "stash": "string"
}
```

## Response Elements
<a name="API_EvaluateMappingTemplate_ResponseElements"></a>

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](#API_EvaluateMappingTemplate_ResponseSyntax) **   <a name="appsync-EvaluateMappingTemplate-response-error"></a>
The `ErrorDetail` object.  
Type: [ErrorDetail](API_ErrorDetail.md) object

 ** [evaluationResult](#API_EvaluateMappingTemplate_ResponseSyntax) **   <a name="appsync-EvaluateMappingTemplate-response-evaluationResult"></a>
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](#API_EvaluateMappingTemplate_ResponseSyntax) **   <a name="appsync-EvaluateMappingTemplate-response-logs"></a>
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

 ** [outErrors](#API_EvaluateMappingTemplate_ResponseSyntax) **   <a name="appsync-EvaluateMappingTemplate-response-outErrors"></a>
The list of runtime errors that are added to the GraphQL operation response.  
Type: String  
Pattern: `^[\s\S]*$` 

 ** [stash](#API_EvaluateMappingTemplate_ResponseSyntax) **   <a name="appsync-EvaluateMappingTemplate-response-stash"></a>
An object available inside each resolver and function handler. A single `stash` object lives through a single resolver run. Therefore, you can use the stash to pass arbitrary data across request and response handlers and across functions in a pipeline resolver.  
Type: String  
Pattern: `^[\s\S]*$` 

## Errors
<a name="API_EvaluateMappingTemplate_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** 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.    
 ** detail **   
Provides further details for the reason behind the bad request. For reason type `CODE_ERROR`, the detail will contain a list of code errors.  
 ** reason **   
Provides context for the cause of the bad request. The only supported value is `CODE_ERROR`.
HTTP Status Code: 400

 ** InternalFailureException **   
An internal AWS AppSync error occurred. Try your request again.  
HTTP Status Code: 500

## See Also
<a name="API_EvaluateMappingTemplate_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/appsync-2017-07-25/EvaluateMappingTemplate) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/appsync-2017-07-25/EvaluateMappingTemplate) 