PleaseDontHurtMe.jpeg
PleaseDontHurtMe.jpeg

Reputation: 53

Why is my resolver query function not returning items from dynamodb that has an sk value above 9999

I tried my best to make it make sense as much as possible with the knowledge I have, I am trying to learn AWS Appsync + DynamoDB and VTL. Thanks

I have a simple query like this using VTL:

{
    "version" : "2017-02-28",
    "operation" : "Query",
    "query" : {
        "expression": "pk = :pk",
        "expressionValues" : {
            ":pk" : $util.dynamodb.toDynamoDBJson("JOB#")
        },
    },
    "scanIndexForward" : false,
    "limit": $util.defaultIfNull(${ctx.args.limit}, 50),
    "nextToken": $util.toJson($util.defaultIfNullOrBlank($ctx.args.nextToken, null)),
}

The limit works as expected and only returns 50 items, as well as returns the data I need (sort of). The problem is, the DynamoDB is setup that the sk is a string, and items that were being created in the database has their sk auto increment by querying the most recent item in the database and doing + 1.

Once the value of the sk is past 9999 they get excluded from the query, as well as from the function which creates these items in the database as it queries the most recent and it always returns 9999 which overwrites the most recent 10000th item.

I am not trying to query 10,000 items at once, it's just items containing an sk past '9999' are excluded in the query.

I can confirm that the 10,000th item is actually being created and I can see it in DynamoDB. I am sure and have checked I am using / referring to the correct data source for my resolver function.

I expected it to work as it always have been - querying the database table and returning the items with the pk JOB#. This problem only occurred on the 10,000th value.

I have tried cloning the 10,000th item and give it's SK value of 10001 and it still shows in the DynamoDB table as well as in my project, but the SK is being listed as 10000.

Upvotes: 0

Views: 93

Answers (0)

Related Questions