EvaluateMappingTemplateCommand

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).

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { AppSyncClient, EvaluateMappingTemplateCommand } from "@aws-sdk/client-appsync"; // ES Modules import
// const { AppSyncClient, EvaluateMappingTemplateCommand } = require("@aws-sdk/client-appsync"); // CommonJS import
const client = new AppSyncClient(config);
const input = { // EvaluateMappingTemplateRequest
  template: "STRING_VALUE", // required
  context: "STRING_VALUE", // required
};
const command = new EvaluateMappingTemplateCommand(input);
const response = await client.send(command);
// { // EvaluateMappingTemplateResponse
//   evaluationResult: "STRING_VALUE",
//   error: { // ErrorDetail
//     message: "STRING_VALUE",
//   },
//   logs: [ // Logs
//     "STRING_VALUE",
//   ],
//   stash: "STRING_VALUE",
//   outErrors: "STRING_VALUE",
// };

EvaluateMappingTemplateCommand Input

Parameter
Type
Description
context
Required
string | undefined

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

template
Required
string | undefined

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

EvaluateMappingTemplateCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
error
ErrorDetail | undefined

The ErrorDetail object.

evaluationResult
string | undefined

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

logs
string[] | undefined

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

outErrors
string | undefined

The list of runtime errors that are added to the GraphQL operation response.

stash
string | undefined

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.

Throws

Name
Fault
Details
AccessDeniedException
client

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

BadRequestException
client

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.

InternalFailureException
server

An internal AppSync error occurred. Try your request again.

AppSyncServiceException
Base exception class for all service exceptions from AppSync service.