0
0
DynamoDBquery~30 mins

AppSync with DynamoDB (GraphQL) - Mini Project: Build & Apply

Choose your learning style9 modes available
AppSync with DynamoDB (GraphQL)
📖 Scenario: You are building a simple backend for a book store using AWS AppSync and DynamoDB. The store needs to keep track of books with their titles and authors.
🎯 Goal: Create a DynamoDB table and a GraphQL schema to store books with titles and authors and query books by ID using AppSync.
📋 What You'll Learn
Create a DynamoDB table named Books with id as the primary key
Define a GraphQL schema with a Book type containing id, title, and author
Add a query getBookById to fetch a book by its id
Add a mutation addBook to add a new book to the table
💡 Why This Matters
🌍 Real World
This project simulates building a backend for a book store app using AWS AppSync and DynamoDB, common in serverless web and mobile applications.
💼 Career
Understanding how to connect GraphQL APIs with DynamoDB is valuable for cloud developers, backend engineers, and anyone working with AWS serverless technologies.
Progress0 / 4 steps
1
Create DynamoDB Table
Create a DynamoDB table named Books with a primary key called id of type String.
DynamoDB
Need a hint?

Use TableName to name the table and define id as the HASH key with type S for string.

2
Define GraphQL Schema
Define a GraphQL type called Book with fields id (ID!), title (String!), and author (String!).
DynamoDB
Need a hint?

Use type Book { ... } to define the fields with exclamation marks to mark them as required.

3
Add Query and Mutation
Add a query called getBookById that takes id: ID! and returns a Book. Add a mutation called addBook that takes id: ID!, title: String!, and author: String! and returns a Book.
DynamoDB
Need a hint?

Define type Query and type Mutation with the specified fields and arguments.

4
Complete AppSync Resolver Mapping
Add the resolver mapping templates for getBookById query and addBook mutation to connect AppSync with the DynamoDB Books table. Use id as the key for getBookById and pass id, title, and author as the item for addBook.
DynamoDB
Need a hint?

Use GetItem operation with id key for the query resolver. Use PutItem with id, title, and author attributes for the mutation resolver.