AWS AppSync for iOS
Learn how to consume GraphQL APIs in your SwiftUI iOS apps in a simple and type-safe way using AWS AppSync framework. By Jessy Catterwaul.
Who is this for?
This course is intended for developers who are interested in learning how to integrate Amazon’s BaaS technology. A good understanding of Swift, SwiftUI, and Combine will be helpful for following along with integration into the app you’ll be working on in this course.
Covered concepts
- AWS AppSync
- AWS Amplify
- GraphQL
Part 1: AppSync Setup with Amplify
Get an overview of Amazon’s BaaS offering, AppSync, along with their Amplify framework. They work together to add a back end component to your iOS app.
AWS AppSync acts as a bridge between GraphQL and other AWS services such as data storage, caching and real-time updates.
npm (Node Package Manager) is a command line interface (CLI) for managing Node.js packages. You’ll need npm installed for installing AWS Amplify.
npm makes it simple to install Amplify. All you need to do is bring an AWS account, which is simple and easy to set up.
You can employ the Swift Package Manager for installation of all the Amplify libraries you will need.
Using a GraphQL schema, you can tell Amplify what models to generate. Afterwards, you’ll be able to interact with them using Swift.
You’ve created a user, set up an app, and added it to the AWS dashboard. You also created a GraphQL API and published it to AWS. You’re all set up to use AppSync!
Part 2: Integrate AppSync into an App
With the libraries installed, and models generated, it’s time to make RazeList, a to-do app, come to life!
Before “configuring” Amplify, you’ll need to import libraries, and create instances of appropriate plugins.
Create a Row view that will correspond with a Todo instance. Then, add some published Todos to the view model.
Create two sections: one for to-dos that you still need doing, and the other, for ones you’ve completed.
The final step of getting the UI working, before we get back to focusing on AppSync specifically, is to integrate the “add to do” screen.
Amplify has save and query methods which makes interacting with the cloud a breeze. You can either use them with Combine, or deal with them synchronously.
So far, the app is great for showing you what you need to do — but not so good at letting you complete those tasks. AppSync to the rescue, again!
The final thing you need to add is a way to delete rows. Swipe-to-delete already exists in the UI, so you just need to wire it up.
You now know the basics of integrating and using AppSync with Amplify in your iOS apps — but there’s a lot more to learn!