AWS AppSync
AWS AppSync Developer Guide

Resolver Mapping Template Reference for None Data Source

The AWS AppSync resolver mapping template used with the Data Source of type None, enables you to shape requests for AWS AppSync local operations.

Request a Mapping Template

The mapping template is simple and enables you to pass as much context information as possible via the payload field.

{ "version": string, "payload": any type }

Here is the JSON schema representation of the request mapping template, once resolved:

{ "definitions": {}, "$schema": "http://json-schema.org/draft-06/schema#", "$id": "http://aws.amazon.com/appsync/request-mapping-template.json", "type": "object", "properties": { "version": { "$id": "/properties/version", "type": "string", "enum": [ "2017-02-28" ], "title": "The Mapping template version.", "default": "2017-02-28" }, "payload": {} }, "required": [ "version" ], "additionalProperties": false }

Here is an example where we chose to pass the field arguments via the VTL context property $context.arguments:

{ "version": "2017-02-28", "payload": $utils.toJson($context.arguments) }

The value of the payload field will be forwarded to the response mapping template and available on the VTL context property ($context.result).

This is an example representing the interpolated value of the payload field:

{ "id": "postId1" }

version

Common to all request mapping templates, version defines the version used by the template.

version is required.

Example:

"version": "2017-02-28"

payload

The payload field is a container that can be used to pass any well-formed JSON to the response mapping template.

payload is optional.

Response Mapping Template

Because there is no data source, the value of the payload field will be forwarded to the response mapping template and set on the context object that is available via the VTL $context.result property.

If the shape of the payload field value exactly matches the shape of the GraphQL type, you can forward the response using the following response mapping template:

$utils.toJson($context.result)

There are no required fields or shape restrictions that apply to the response mapping template. However, because GraphQL is strongly typed, the resolved mapping template must match the expected GraphQL type.