Given a DynamoDB table Books with items having id and title, and this GraphQL query:
{ getBook(id: "123") { id title } }Assuming the item with id = "123" exists with title "Learn GraphQL", what is the expected output?
Think about what the resolver returns when the item exists.
The resolver fetches the item by id and returns all requested fields. Since the item exists, the data is returned with id and title.
In an AppSync DynamoDB resolver, you want to get an item by id from the Books table. Which Velocity Template Language (VTL) snippet is syntactically correct?
Remember DynamoDB expects attribute types in the key.
Option A correctly specifies the operation as GetItem and the key with attribute type S (string) for id. Option A misses the attribute type, C uses Query instead of GetItem, and A uses N (number) which is incorrect if id is a string.
You want to filter Books by author attribute, which is not a key. Which approach optimizes performance in AppSync with DynamoDB?
Think about how DynamoDB handles queries on non-key attributes efficiently.
Scan reads the entire table and is slow. GetItem requires key attributes, which author is not. BatchGetItem requires keys too. Creating a GSI on author allows efficient Query operations.
Given this VTL request mapping template:
{
"version": "2018-05-29",
"operation": "GetItem",
"key": {
"id": { "S": "$ctx.args.bookId" }
}
}And the GraphQL query:
{ getBook(id: "abc123") { id title } }The item with id = "abc123" exists, but the response is null. What is the likely cause?
Check if the argument names match between query and resolver.
The resolver expects bookId argument but the query provides id. This mismatch causes the key to be empty, so DynamoDB returns no item, resulting in null.
Choose the best explanation of why DynamoDB is a good choice for AppSync real-time GraphQL APIs.
Think about performance and integration benefits.
DynamoDB offers very low latency and integrates natively with AppSync, making it ideal for real-time GraphQL APIs. It does not support relational joins or automatic schema generation, nor does it store XML data.