aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
507 stars 32 forks source link

How to query? #220

Closed NiksanJP closed 10 months ago

NiksanJP commented 2 years ago

My resolver template

{
   "version" : "2017-02-28",
    "operation" : "Query",
    "query" : {
        "expression" : "receiverusername = :receiverusername and createdat > :createdat",
        "expressionValues" : {
            ":receiverusername" : $util.dynamodb.toDynamoDBJson($context.identity.username),
            ":createdat" : $util.dynamodb.toDynamoDBJson($ctx.args.input.lastDate),
        }
    },
    "index" : "receiverusername-createdat-index",
}

I am trying to query the date and username but I keep on getting this error

{
  "data": {
    "listMyMessages": null
  },
  "errors": [
    {
      "path": [
        "listMyMessages"
      ],
      "data": null,
      "errorType": "DynamoDB:DynamoDbException",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "One or more parameter values were invalid: Condition parameter type does not match schema type (Service: DynamoDb, Status Code: 400, Request ID: 7I18ODEK46H52NMBSF99OTNSQ7VV4KQNSO5AEMVJF66Q9ASUAAJG)"
    }
  ]

How do I query this ?

onlybakam commented 10 months ago

Hello, please consider using the new DDB modules to interact with your DynamoDB data source using a JavaScript resolver. https://aws.amazon.com/blogs/mobile/introducing-new-aws-appsync-module-and-functions-for-dynamodb-javascript-resolvers/

The module makes it easier to properly query your table. Right now you may have some syntax errors in your expression.