I am trying to build an AWS AppSync query with a list using IN
:
{
"version" : "2017-02-28",
"operation" : "Query",
"index" : "my-index",
"query" : {
"expression": "id IN :ids",
"expressionValues" : { ":ids" : $util.dynamodb.toStringSet($ctx.args.ids) }
},
"limit": $util.defaultIfNull(${ctx.args.first}, 20),
"nextToken": $util.toJson($util.defaultIfNullOrBlank($ctx.args.after, null))
}
However, trying it out with parameters like:
query ListItemsWithIdList {
listItemsWithIdList(first:20, ids: ["id1", "id2"]) {
items {
id
}
nextToken
}
}
It throws an error:
Unable to parse the JSON document: 'Unexpected character ('S' (code 83)): was expecting double-quote to start field name
at [Source: (String)\"{
\"version\" : \"2017-02-28\",
\"operation\" : \"Query\",
\"index\" : \"my-index\",
\"query\" : {
\"expression\": \"id IN :ids\",
\"expressionValues\" : { \":ids\" : {SS=[id1, id2]} }
},
\"limit\": 20,
\"nextToken\": null
}\"; line: 7, column: 47]'"
It seems OK to use IN
for query comparison operator; however, how can I pass a String List
as a parameter and fetch the results whose IDs are among those parameters supplied?
EDIT: Corrected variable name typo.