AWS AppSync
AWS AppSync Developer Guide

Resolver Mapping Template Reference for RDS

The AWS Appsync RDS resolver mapping templates allow developers to send SQL queries to an Data API for Aurora Serverless and get back the result of these queries.

Request Mapping Template

The RDS request mapping template is fairly simple:

{ "version": "2018-05-29", "statements": [], "variableMap": {} }

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

{ "definitions": {}, "$schema": "", "$id": "", "type": "object", "title": "The Root Schema", "required": [ "version", "statements", "variableMap" ], "properties": { "version": { "$id": "#/properties/version", "type": "string", "title": "The Version Schema", "default": "", "examples": [ "2018-05-29" ], "enum": [ "2018-05-29" ], "pattern": "^(.*)$" }, "statements": { "$id": "#/properties/statements", "type": "array", "title": "The Statements Schema", "items": { "$id": "#/properties/statements/items", "type": "string", "title": "The Items Schema", "default": "", "examples": [ "SELECT * from BOOKS" ], "pattern": "^(.*)$" } }, "variableMap": { "$id": "#/properties/variableMap", "type": "object", "title": "The Variablemap Schema" } } }

The following is an example of request mapping template with a static query:

{ "version": "2018-05-29", "statements": [ "select title, isbn13 from BOOKS where author = 'Mark Twain'" ] }


Common to all request mapping templates, version defines the version that the template uses. version is required. The "2018-05-29" is the only version supported for the Amazon RDS mapping templates.

"version": "2018-05-29"


The statements array is a placeholder for the developer provided queries. Currently, we support up to two queries per request mapping template. The following is possible:

{ "version": "2018-05-29", "statements": [ "insert into BOOKS VALUES ('$', '$ctx.args.newBook.title', '$ctx.args.newBook.ISBN13')", "select * from BOOKS WHERE isbn13 = '$ctx.args.newBook.isbn13'" ] }

Currently, AppSync supports up to two statements.


The variableMap is an optional field which contains aliases that can be used to make the SQL statements shorter and more readable. For example the following is possible:

{ "version": "2018-05-29", "statements": [ "insert into BOOKS VALUES (:AUTHOR, :TITLE, :ISBN13)", "select * from BOOKS WHERE isbn13 = :ISBN13" ], "variableMap": { ":AUTHOR": "$", ":TITLE": "$ctx.args.newBook.title", ":ISBN13": "$ctx.args.newBook.isbn13" } }

Appsync will use the variable map value to construct the queries that are sent to the Aurora Serverless Data API. For example the two queries that AWS Appsync will send to Amazon RDS will be (assming “$"='Mark Twain', "$ctx.args.newBook.title"='Adventures of Huckleberry Finn' and "$ctx.args.newBook.isbn13"='978-1948132817'):

INSERT INTO BOOKS VALUES ('Mark Twain', 'Adventures of Huckleberry Finn', '978-1948132817');


SELECT from BOOKS where isb13='978-1948132817';