Transformation helpers in $util.transform
Note
We now primarily support the APPSYNC_JS runtime and its documentation. Please consider using the APPSYNC_JS runtime and its guides here.
$util.transform contains helper methods that make it easier to perform
complex operations against data sources, such as Amazon DynamoDB filter operations.
Transformation helpers
$util.transform.toDynamoDBFilterExpression(Map) : Map-
Converts an input string to a filter expression for use with DynamoDB.
Input: $util.transform.toDynamoDBFilterExpression({ "title":{ "contains":"Hello World" } }) Output: { "expression" : "contains(#title, :title_contains)" "expressionNames" : { "#title" : "title", }, "expressionValues" : { ":title_contains" : { "S" : "Hello World" } }, } $util.transform.toElasticsearchQueryDSL(Map) : Map-
Converts the given input into its equivalent OpenSearch Query DSL expression, returning it as a JSON string.
Input: $util.transform.toElasticsearchQueryDSL({ "upvotes":{ "ne":15, "range":[ 10, 20 ] }, "title":{ "eq":"hihihi", "wildcard":"h*i" } }) Output: { "bool":{ "must":[ { "bool":{ "must":[ { "bool":{ "must_not":{ "term":{ "upvotes":15 } } } }, { "range":{ "upvotes":{ "gte":10, "lte":20 } } } ] } }, { "bool":{ "must":[ { "term":{ "title":"hihihi" } }, { "wildcard":{ "title":"h*i" } } ] } } ] } }The default operator is assumed to be AND.
Transformation helpers subscription filters
$util.transform.toSubscriptionFilter(Map) : Map-
Converts a
Mapinput object to aSubscriptionFilterexpression object. The$util.transform.toSubscriptionFiltermethod is used as an input to the$extensions.setSubscriptionFilter()extension. For more information, see Extensions. $util.transform.toSubscriptionFilter(Map, List) : Map-
Converts a
Mapinput object to aSubscriptionFilterexpression object. The$util.transform.toSubscriptionFiltermethod is used as an input to the$extensions.setSubscriptionFilter()extension. For more information, see Extensions.The first argument is the
Mapinput object that's converted to theSubscriptionFilterexpression object. The second argument is aListof field names that are ignored in the firstMapinput object while constructing theSubscriptionFilterexpression object. $util.transform.toSubscriptionFilter(Map, List, Map) : Map-
Converts a
Mapinput object to aSubscriptionFilterexpression object. The$util.transform.toSubscriptionFiltermethod is used as an input to the$extensions.setSubscriptionFilter()extension. For more information, see Extensions.The first argument is the
Mapinput object that's converted to theSubscriptionFilterexpression object, the second argument is aListof field names that will be ignored in the firstMapinput object, and the third argument is aMapinput object of strict rules that's included while constructing theSubscriptionFilterexpression object. These strict rules are included in theSubscriptionFilterexpression object in such a way that at least one of the rules will be satisfied to pass the subscription filter.
Subscription filter arguments
The following table explains the how the arguments of the following utilities are defined:
-
$util.transform.toSubscriptionFilter(Map) : Map -
$util.transform.toSubscriptionFilter(Map, List) : Map -
$util.transform.toSubscriptionFilter(Map, List, Map) : Map