2

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.

xaxist
  • 598
  • 5
  • 9
  • I added an answer [here](https://stackoverflow.com/questions/53083366/how-to-set-aws-appsync-request-timeout-limit-awsappsync-client-not-giving-cal/53139361#53139361). Can you try that? – Kamran Nov 04 '18 at 09:32
  • Hello @Kamran, I have added the urlSessionConfiguration while configuring the AppSync, but still not sure where to catch the "HTTP load failed" error. Any leads on that? – xaxist Nov 05 '18 at 20:03
  • 1
    Update: This issue has been fixed with AppSync SDK 2.7.0. Here's the Github thread https://github.com/awslabs/aws-mobile-appsync-sdk-ios/issues/91#issuecomment-440550288 – xaxist Nov 21 '18 at 06:28

0 Answers0