0
0
DynamoDBquery~20 mins

AppSync with DynamoDB (GraphQL) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
AppSync DynamoDB Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this GraphQL query with DynamoDB resolver?

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?

A{"data": {"getBook": null}}
B{"data": {"getBook": {"id": "123", "title": "Learn GraphQL"}}}
C{"errors": [{"message": "Item not found"}]}
D{"data": {"getBook": {"id": "123"}}}
Attempts:
2 left
💡 Hint

Think about what the resolver returns when the item exists.

📝 Syntax
intermediate
2:00remaining
Which VTL snippet correctly retrieves an item by id in DynamoDB resolver?

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?

A
{
  "version": "2018-05-29",
  "operation": "GetItem",
  "key": {
    "id": { "S": "$ctx.args.id" }
  }
}
B
{
  "version": "2018-05-29",
  "operation": "GetItem",
  "key": {
    "id": "$ctx.args.id"
  }
}
C
{
  "version": "2018-05-29",
  "operation": "Query",
  "key": {
    "id": { "S": "$ctx.args.id" }
  }
}
D
{
  "version": "2018-05-29",
  "operation": "GetItem",
  "key": {
    "id": { "N": "$ctx.args.id" }
  }
}
Attempts:
2 left
💡 Hint

Remember DynamoDB expects attribute types in the key.

optimization
advanced
2:00remaining
How to optimize a DynamoDB resolver for filtering items by a non-key attribute?

You want to filter Books by author attribute, which is not a key. Which approach optimizes performance in AppSync with DynamoDB?

AUse BatchGetItem operation with <code>author</code> values.
BUse a Scan operation with a filter expression on <code>author</code>.
CCreate a Global Secondary Index (GSI) on <code>author</code> and use Query operation on the GSI.
DUse GetItem operation with <code>author</code> as key.
Attempts:
2 left
💡 Hint

Think about how DynamoDB handles queries on non-key attributes efficiently.

🔧 Debug
advanced
2:00remaining
Why does this AppSync resolver return null for an existing item?

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?

AThe request mapping uses <code>$ctx.args.bookId</code> but the query argument is <code>id</code>.
BThe DynamoDB table does not have an item with <code>id = "abc123"</code>.
CThe response mapping template is missing.
DThe operation should be Query instead of GetItem.
Attempts:
2 left
💡 Hint

Check if the argument names match between query and resolver.

🧠 Conceptual
expert
2:00remaining
What is a key benefit of using DynamoDB with AppSync for real-time GraphQL APIs?

Choose the best explanation of why DynamoDB is a good choice for AppSync real-time GraphQL APIs.

ADynamoDB stores data in XML format which AppSync parses efficiently for real-time APIs.
BDynamoDB supports flexible relational joins which AppSync uses for real-time updates.
CDynamoDB automatically generates GraphQL schemas for AppSync without configuration.
DDynamoDB's single-digit millisecond latency and seamless integration with AppSync enable fast real-time data access.
Attempts:
2 left
💡 Hint

Think about performance and integration benefits.