AWS AppSync is a service that makes it easy to build GraphQL APIs by handling the heavy lifting of securely connecting to data sources like DynamoDB, Lambda, and more.
Click to reveal answer
beginner
How does AppSync connect to DynamoDB?
AppSync connects to DynamoDB using resolvers that translate GraphQL requests into DynamoDB operations like GetItem, PutItem, Query, and Scan.
Click to reveal answer
beginner
What is a resolver in AppSync?
A resolver is a piece of code or configuration that tells AppSync how to fetch or modify data from a data source when a GraphQL query or mutation is executed.
Click to reveal answer
intermediate
Why use GraphQL with DynamoDB via AppSync instead of direct DynamoDB calls?
GraphQL with AppSync provides a flexible API that lets clients request exactly the data they need, reduces over-fetching, and simplifies real-time updates and offline support.
Click to reveal answer
intermediate
What is a common pattern for modeling data in DynamoDB for AppSync?
A common pattern is to use a single table design with partition keys and sort keys to efficiently query related data, enabling fast and flexible access through GraphQL queries.
Click to reveal answer
What does a resolver in AppSync do?
ATranslates GraphQL requests to data source operations
BStores data in DynamoDB
CCreates GraphQL schemas
DManages user authentication
✗ Incorrect
Resolvers translate GraphQL queries or mutations into operations on data sources like DynamoDB.
Which AWS service is used to build GraphQL APIs that connect to DynamoDB?
AAWS Lambda
BAmazon S3
CAmazon RDS
DAWS AppSync
✗ Incorrect
AWS AppSync is the service designed to build GraphQL APIs and connect them to data sources like DynamoDB.
In AppSync, what type of DynamoDB operation would a 'Query' resolver perform?
ARetrieve multiple items based on partition key and optional sort key
BDelete a single item
CAdd a new item
DScan the entire table
✗ Incorrect
A Query operation retrieves items matching a partition key and optionally a sort key, which is efficient for related data.
What is a benefit of using GraphQL with AppSync over REST APIs for DynamoDB?
AGraphQL does not support mutations
BClients can request only the data they need
CAppSync automatically creates tables
DGraphQL requires no schema
✗ Incorrect
GraphQL lets clients specify exactly which fields they want, reducing over-fetching compared to REST.
Which of these is NOT a typical data source for AppSync?
ADynamoDB
BAmazon S3
CAmazon EC2
DAWS Lambda
✗ Incorrect
Amazon EC2 is a compute service, not a typical direct data source for AppSync.
Explain how AWS AppSync works with DynamoDB to serve GraphQL requests.
Think about the flow from client to database and back.
You got /4 concepts.
Describe the advantages of using GraphQL with AppSync over direct DynamoDB API calls.
Consider client experience and API flexibility.
You got /4 concepts.
Practice
(1/5)
1. What is the main benefit of using AWS AppSync with DynamoDB in an application?
easy
A. It allows apps to request only the data they need using GraphQL.
B. It automatically creates SQL tables for data storage.
C. It requires manual scaling of the database.
D. It replaces the need for any backend code.
Solution
Step 1: Understand AppSync's role
AppSync uses GraphQL to let apps ask for exactly the data they need, avoiding over-fetching.
Step 2: Understand DynamoDB's role
DynamoDB stores data quickly and scales automatically, but does not create SQL tables or replace backend code entirely.
Final Answer:
It allows apps to request only the data they need using GraphQL. -> Option A
Quick Check:
AppSync + GraphQL = precise data requests [OK]
Hint: Remember: AppSync uses GraphQL for precise data fetching [OK]
Common Mistakes:
Thinking DynamoDB creates SQL tables
Believing manual scaling is needed
Assuming AppSync removes all backend code
2. Which of the following is the correct way to define a DynamoDB data source in an AWS AppSync GraphQL schema?
easy
A. type Query { getItem(id: ID!): Item @aws_dynamodb(tableName: MyTable) }
B. type Query { getItem(id: ID!): Item @aws_lambda(functionName: "MyFunction") }
C. type Query { getItem(id: ID!): Item @aws_dynamodb(tableName: "MyTable", region: "us-east-1") }
D. type Query { getItem(id: ID!): Item @aws_s3(bucketName: "MyBucket") }
Solution
Step 1: Identify the correct directive for DynamoDB
The @aws_dynamodb directive is used to link a DynamoDB table as a data source in AppSync.
Step 2: Check syntax correctness
type Query { getItem(id: ID!): Item @aws_dynamodb(tableName: "MyTable", region: "us-east-1") } correctly includes the tableName and region parameters, which are valid for specifying the DynamoDB data source.
Final Answer:
type Query { getItem(id: ID!): Item @aws_dynamodb(tableName: "MyTable", region: "us-east-1") } -> Option C
Quick Check:
@aws_dynamodb with tableName and region is correct syntax [OK]
Hint: Look for @aws_dynamodb with tableName and region parameters [OK]
Common Mistakes:
Using @aws_lambda instead of @aws_dynamodb for DynamoDB
Forgetting quotes around tableName value
Using @aws_s3 which is unrelated to DynamoDB
3. Given this GraphQL query in AppSync linked to DynamoDB:
query GetBook { getBook(id: "123") { id title author } }
5. You want to create a real-time chat app using AppSync and DynamoDB. Which approach best ensures that clients receive new messages instantly without polling?
hard
A. Have clients poll DynamoDB every few seconds for new messages.
B. Use AppSync subscriptions linked to DynamoDB streams to push updates to clients.
C. Use a Lambda function to write messages to DynamoDB and notify clients via email.
D. Store messages in DynamoDB and refresh the UI only when the app restarts.
Solution
Step 1: Understand real-time updates in AppSync
AppSync supports GraphQL subscriptions that can push data to clients when data changes.
Step 2: Connect DynamoDB streams to subscriptions
DynamoDB streams capture table changes and can trigger AppSync subscriptions to notify clients instantly.
Step 3: Evaluate other options
Polling wastes resources, email notifications are slow and unrelated, and UI refresh on restart is not real-time.
Final Answer:
Use AppSync subscriptions linked to DynamoDB streams to push updates to clients. -> Option B