Bird
0
0

A resolver mapping template for a DynamoDB Query operation uses this snippet:

medium📝 Debug Q7 of 15
DynamoDB - with Serverless
A resolver mapping template for a DynamoDB Query operation uses this snippet:
{"version": "2018-05-29", "operation": "Query", "query": {"expression": "#pk = :pk", "expressionNames": {"#pk": "partitionKey"}, "expressionValues": {":pk": "$ctx.args.pk"}}}

Why does this cause a runtime error?
AExpression values must be wrapped with DynamoDB types like {"S": "value"}
BThe operation "Query" is not valid for DynamoDB in AppSync
CExpression names cannot use # symbol
DPartition key attribute name must be "id"
Step-by-Step Solution
Solution:
  1. Step 1: Review expressionValues format

    Expression values in DynamoDB VTL must specify data types, e.g., {"S": "value"} for strings.
  2. Step 2: Identify missing type wrappers

    The snippet uses ":pk": "$ctx.args.pk" without wrapping in DynamoDB type, causing error.
  3. Final Answer:

    Expression values must be wrapped with DynamoDB types like {"S": "value"} -> Option A
  4. Quick Check:

    Expression values need type wrappers = D [OK]
Quick Trick: Wrap expression values with DynamoDB types in queries [OK]
Common Mistakes:
MISTAKES
  • Omitting type wrappers in expressionValues
  • Misusing operation names
  • Incorrect attribute naming assumptions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes