Bird
0
0

Given this GraphQL query in AppSync linked to DynamoDB:

medium📝 query result Q13 of 15
DynamoDB - with Serverless
Given this GraphQL query in AppSync linked to DynamoDB:
query GetBook { getBook(id: "123") { id title author } }

And the DynamoDB table has an item:
{"id": "123", "title": "Learn DynamoDB", "author": "Jane"}

What will be the output of this query?
A{"data": {"getBook": {"id": "123", "title": "Learn DynamoDB", "author": "Jane"}}}
B{"data": {"getBook": null}}
C{"errors": [{"message": "Item not found"}]}
D{"data": {"getBook": {"id": "123", "title": null, "author": null}}}
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query and data

    The query requests the item with id "123" and fields id, title, author. The table has this exact item.
  2. Step 2: Predict the query result

    Since the item exists, the query returns all requested fields with their values.
  3. Final Answer:

    {"data": {"getBook": {"id": "123", "title": "Learn DynamoDB", "author": "Jane"}}} -> Option A
  4. Quick Check:

    Existing item returns full data [OK]
Quick Trick: If item exists, query returns requested fields with values [OK]
Common Mistakes:
MISTAKES
  • Assuming null fields if item exists
  • Expecting errors when item is present
  • Confusing null result with missing item

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes