Bird
0
0

You want to implement a GraphQL mutation in AppSync that updates a user's email only if the user exists in DynamoDB. Which resolver operation and condition should you use in the mapping template?

hard🚀 Application Q8 of 15
DynamoDB - with Serverless
You want to implement a GraphQL mutation in AppSync that updates a user's email only if the user exists in DynamoDB. Which resolver operation and condition should you use in the mapping template?
AUse UpdateItem operation with a condition expression checking attribute_exists(id)
BUse PutItem operation without any condition expression
CUse DeleteItem operation with a condition expression checking attribute_not_exists(email)
DUse Query operation with a filter expression on email
Step-by-Step Solution
Solution:
  1. Step 1: Choose operation to update existing item

    UpdateItem modifies attributes of an existing item and supports condition expressions.
  2. Step 2: Use condition to ensure item exists

    Condition expression attribute_exists(id) ensures update only if user exists.
  3. Final Answer:

    UpdateItem with condition expression attribute_exists(id) -> Option A
  4. Quick Check:

    Update with condition to check existence = B [OK]
Quick Trick: Use UpdateItem with attribute_exists condition to update safely [OK]
Common Mistakes:
MISTAKES
  • Using PutItem which overwrites without condition
  • Using DeleteItem incorrectly
  • Using Query instead of update operation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes