aws / aws-appsync-community

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

Unexpected behavior of DynamoDB projection expression feature #274

Closed sstaradubet closed 1 year ago

sstaradubet commented 1 year ago

Hey

I have faced with unexpected behavior of DynamoDB projection feature.

Request template

{
    "version" : "2018-05-29",
    "operation" : "GetItem",
    "key" : {
        "PartitionKey" : { "S" : "PartitionKey" },
        "SortKey" : { "S" : "SortKey" }
    },
    "projection": {
        "expression": "PartitionKey, SortKey, CreatedDate, UpdatedDate, Name, AttributesMap.Attribute1, AttributesMap.Attribute2"
    },
    "consistentRead" : false
}

In the case of AttributesMap.Attribute2 not exists for the requested DynamoDB item request returns a null item from DynamoDB. Expected behavior, DynamoDB will return an item with all existing attributes from the projection expression and skip absent attributes (it works in this way in Python and Java SDK).

Thanks in advance!

harish1454 commented 1 year ago

Hello, thanks for reaching out to us.

I have tried to reproduce the issue, but I see that DynamoDB returning the response by skipping the absent attributes in projection expression to AppSync, which is expected. I verified this by enabling ALL logs on my API and inspecting the result field in ResponseMapping log event for that request, you can also do the same.

If you still need help, please share your logs for that request, schema, request and response mapping templates and a sample item from the DynamoDB table. Thanks!