Skip to content

Instantly share code, notes, and snippets.

@mobilequickie
Created May 24, 2019 05:23
Show Gist options
  • Save mobilequickie/ec88d9062c02821f24b44c2b0079ac98 to your computer and use it in GitHub Desktop.
Save mobilequickie/ec88d9062c02821f24b44c2b0079ac98 to your computer and use it in GitHub Desktop.
import UIKit
import AWSAppSync // #1
class AWSServicesTableViewController: UITableViewController {
// Reference AppSync client
var appSyncClient: AWSAppSyncClient? // #2
// Sample data
override func viewDidLoad() {
super.viewDidLoad()
initializeAppSync() // #3
}
// #4
// Use this code when setting up AppSync with API_key auth mode. This mode is used for testing our GraphQL mutations, queries, and subscriptions with an API key.
func initializeAppSync() {
do {
// Initialize the AWS AppSync configuration
let appSyncConfig = try AWSAppSyncClientConfiguration(appSyncServiceConfig: AWSAppSyncServiceConfig(),
cacheConfiguration: AWSAppSyncCacheConfiguration())
// Initialize the AWS AppSync client
appSyncClient = try AWSAppSyncClient(appSyncConfig: appSyncConfig)
} catch {
print("Error initializing appsync client. \(error)")
}
}
// End #4
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment