Page updated Jan 16, 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 } }
1let mutationInput = CreateTodoInput(name: "Use AppSync", description:"Realtime and Offline")
2
3appSyncClient?.perform(mutation: CreateTodoMutation(input: mutationInput)) { (result, error) in
4 if let error = error as? AWSAppSyncClientError {
5 print("Error occurred: \(error.localizedDescription )")
6 }
7 if let resultError = result?.errors {
8 print("Error saving the item on server: \(resultError)")
9 return
10 }
11}

Amplify Library for Swift:

  1. Update Amplify CLI to the latest version
amplify upgrade
1amplify upgrade
  1. The version should be at least 12.3.0
amplify --v # at least 12.3.0
1amplify --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)") }
1let mutationInput = CreateTodoInput(name: "Use AWSAPIPlugin",
2 description: "Realtime and Offline")
3let request = GraphQLRequest(document: CreateTodoMutation.operationString,
4 variables: CreateTodoMutation(input: mutationInput).variables?.jsonObject,
5 responseType: CreateTodoMutation.Data.self)
6
7do {
8 let result = try await Amplify.API.mutate(request: request)
9 switch result {
10 case .success(let todo):
11 print("Successfully created todo: \(todo)")
12 case .failure(let error):
13 print("Got failed result with \(error.errorDescription)")
14 }
15} catch let error as APIError {
16 print("Failed to update todo: ", error)
17} catch {
18 print("Unexpected error: \(error)")
19}

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.