- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
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 |
---|
Parameter | Type | Description |
---|---|---|
context Required | string | undefined | The map that holds all of the contextual information for your resolver invocation. A |
template Required | string | undefined | The mapping template; this can be a request or response template. A |
EvaluateMappingTemplateCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
error | ErrorDetail | undefined | The |
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 |
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 |
Throws
Name | Fault | Details |
---|
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. |