Maxime Franchot
Maxime Franchot

Reputation: 1103

How to use multiple filter expressions in AppSync resolver

I can't for the life of me figure out how to have two different filter expressions in my Appsync resolver. I'm trying to retrieve the ID based on the two other pieces of data, email and username.

Here's how my resolver looks like:

{
  "version" : "2017-02-28",
  "operation" : "Scan",
  "filter" : {
    "expression" : "email = :email and username = :username",
    "expressionValues" : {
      ":email" : { "S" : "${context.arguments.email}" },
      ":username" : { "S" : "${context.arguments.username}" },
    },
  }
}

I get data: null as a response even if my request seems valid.

Any tips on how to do this?

Upvotes: 2

Views: 1132

Answers (1)

Naveen S Adhikari
Naveen S Adhikari

Reputation: 46

{
    "version" : "2017-02-28",
    "operation" : "Scan",
    "filter": {
        "expression": "contains(email, :email) AND contains(username, :username)",
        "expressionValues" : {
            ":email": {
                "S": "${ctx.args.email}"
            },
            ":username": {
                "S": "${ctx.args.username}"
            },
        }
    }
}

Upvotes: 3

Related Questions