I am trying my hands on with AppSync iOS and want to get a failure callback for a fetch query when the internet is not available.
When the internet is available, the following code outputs both "sending" and "receiving". But when the internet is not available, I do not get any callback from AppSync client. The code only outputs "sending".
print("sending")
self.appSyncClient?.fetch(query: getCategoriesQuery, cachePolicy: .fetchIgnoringCacheData) { (result, error) in
print("receiving")
if let error = error as? AWSAppSyncClientError {
print("Error getting Categories from AppSync API: \(error.localizedDescription )")
}
else {
print("Result - ", result?.data?.getCategories?.items!)
}
}
After the network timeout, the xCode console outputs
"HTTP load failed (error code: -1001 [1:60])"
"finished with error - code: -1001"
How can I handle the network failure here? Any help is appreciated.