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
Map
input object to aSubscriptionFilter
expression object. The$util.transform.toSubscriptionFilter
method is used as an input to the$extensions.setSubscriptionFilter()
extension. For more information, see Extensions. $util.transform.toSubscriptionFilter(Map, List) : Map
-
Converts a
Map
input object to aSubscriptionFilter
expression object. The$util.transform.toSubscriptionFilter
method is used as an input to the$extensions.setSubscriptionFilter()
extension. For more information, see Extensions.The first argument is the
Map
input object that's converted to theSubscriptionFilter
expression object. The second argument is aList
of field names that are ignored in the firstMap
input object while constructing theSubscriptionFilter
expression object. $util.transform.toSubscriptionFilter(Map, List, Map) : Map
-
Converts a
Map
input object to aSubscriptionFilter
expression object. The$util.transform.toSubscriptionFilter
method is used as an input to the$extensions.setSubscriptionFilter()
extension. For more information, see Extensions.The first argument is the
Map
input object that's converted to theSubscriptionFilter
expression object, the second argument is aList
of field names that will be ignored in the firstMap
input object, and the third argument is aMap
input object of strict rules that's included while constructing theSubscriptionFilter
expression object. These strict rules are included in theSubscriptionFilter
expression 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