Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Upgrade from AppSync SDK

If you're using AWS AppSync SDK for iOS (Maintenance mode), we recommend that you upgrade to the AWS Amplify API category

What does "Maintenance" mean? While in maintenance, the AWS AppSync SDK for iOS will continue to receive updates that ensure compatibility with backend services and security updates. No new features will be introduced in the AWS AppSync SDK for iOS.

How long will Maintenance last? AWS AppSync SDK for iOS will be in Maintenance for 12 months i.e until September 1, 2024, after which no new updates will be made. This may result in the APIs going out of sync with the services and result in breaking production apps.

AWS Amplify provides APIs for querying, mutating, and subscribing to data in AppSync with less configuration overhead. Here's an example of running a query in the AWS AppSync SDK for iOS (Maintenance mode) vs. AWS Amplify API category:

AWS AppSync SDK for iOS (Maintenance mode):

let mutationInput = CreateTodoInput(name: "Use AppSync", description:"Realtime and Offline")
appSyncClient?.perform(mutation: CreateTodoMutation(input: mutationInput)) { (result, error) in
if let error = error as? AWSAppSyncClientError {
print("Error occurred: \(error.localizedDescription )")
}
if let resultError = result?.errors {
print("Error saving the item on server: \(resultError)")
return
}
}

Amplify Library for Swift:

  1. Update Amplify CLI to the latest version
amplify upgrade
  1. The version should be at least 12.3.0
amplify --v # at least 12.3.0
  1. Run amplify codegen types to generate the latest API.swift

  2. In your app, remove the AppSync SDK dependency from your packages

  3. Add AWSAPIPlugin from Amplify

  4. Update your code to use Amplify.API by creating a GraphQL request using the types from API.swift

let mutationInput = CreateTodoInput(name: "Use AWSAPIPlugin",
description: "Realtime and Offline")
let request = GraphQLRequest(document: CreateTodoMutation.operationString,
variables: CreateTodoMutation(input: mutationInput).variables?.jsonObject,
responseType: CreateTodoMutation.Data.self)
do {
let result = try await Amplify.API.mutate(request: request)
switch result {
case .success(let todo):
print("Successfully created todo: \(todo)")
case .failure(let error):
print("Got failed result with \(error.errorDescription)")
}
} catch let error as APIError {
print("Failed to update todo: ", error)
} catch {
print("Unexpected error: \(error)")
}

Optimistic UI and cached data revalidation

If you've used the AWS AppSync SDK's caching capabilities for optimistic UI, then we recommend you to follow our Optimistic UI guide. In this guide, you'll learn how to use AWS Amplify's API category in conjunction with SwiftUI to achieve optimistic UI and cached data invalidation use cases.

Complex objects support

If you were using complex objects in the AWS AppSync SDK for iOS (Maintenance mode), then we recommend you to follow our Working with Files guide. This guide details the recommended path to store file metadata in your GraphQL API records and use Amplify Storage to store blob data in Amazon S3.