Configure an AppSync schema in DynamoDB with help from the experts at Bobcares
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Let’s take a look at how our Support Team is ready to help customers with configuring an AppSync schema in DynamoDB.
How to configure an AppSync schema in DynamoDB
If you are looking for a way to configure an AppSync schema to retrieve a response from an Amazon DynamoDB table with nested JSON data, you are in the right place. According to our Support Engineers, this process involves:
- Adding a nested JSON data item in the DynamoDB table
- Creating an AppSync API and attaching the data source.
- Configuring the nested JSON schema
- Attaching a resolver to the getItems query
- Creating a new test query
Let’s take a closer look at each of these steps to understand how the job gets done.
How to add a nested JSON data item in the DynamoDB table
- First, we have to open the AWS DynamoDB console and select Create table.
- Then, we have to enter a descriptive name in the Table name field.
- Next, we will enter a field name in the Primary key field and then select Create.
- After that, we have to navigate to the Items tab and choose Create item.
- Finally, make a copy of the nested JSON record, paste it into the text item, and click Save.
How to Create an AppSync API and attach the data source
- First, we have to open the AWS AppSync console and select Create API.
- Then, we will head to the Getting Started page which we can find under Customize your API or import from Amazon DynamoDB, and select Build from scratch.
- Next, we have to choose Start and then enter a name for the API in the API name.
- After that, we will choose Create and select Data Sources in the left navigation pane.
- Then we have to select Create data source.
- Next, we have to head New Data Source page, under Create new Data Source. Here we have to make the following changes:
- Enter a descriptive name for the Data source name
- Choose Amazon DynamoDB table for Data source type
- Select the region that contains your DynamoDB table for Region
- Choose the table you just created for the Table name
- Finally, click Create.
How to configure the nested JSON schema in the AppSync API
- First, we have to select Schema in the left navigation pane of the AWS AppSync console.
- Then, we have to copy and paste the nested JSON schema seen below into the text box and click Save:
type Query { getItems(id: String!): allData } type allData { id: String! product: toModel status: String } type items { battery: String device: String pressure: String up_time: String } schema { query: Query } type toModel { model: toProperties } type toProperties { property: items }
How to attach a resolver to the getItems query
- First, we have to navigate to Resolvers on the Schema page of the API in the AWS AppSync console and scroll down to Query. We can also enter Query in the Filter types field.
- Then we will head to getItems(…): allData, under Resolver, and select Attach.
- Next, we have to head to Create new Resolver page and select the name of the DynamoDB table we created earlier as the Data source name.
- After that, we have to select Save Resolvers.
How to create a new test query
- Here, we have to select Queries in the left navigation pane in the AWS AppSync console.
- Then we will head to the Queries and copy and paste the following query in the Query editor:
query getItem { getItems(id:"123") { id product{ model{ property{ pressure device battery up_time } } } status } }
- Finally, we will press Ctrl/Cmd+Enter or select the play icon to run the test query.
[Looking for a solution to another query? We are just a click away.]
Conclusion
To conclude, our skilled Support Engineers at Bobcares demonstrated how to configure an AppSync schema in DynamoDB.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments