Created
March 6, 2022 11:53
-
-
Save chandan-0/9a8934cbc7cd53ff3cc8b1fc73479e25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// Learning GraphQL | |
// | |
// Created by Chandan on 30/01/22. | |
// | |
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
getCountryDetails(countryCode: "IN") | |
// Do any additional setup after loading the view. | |
} | |
} | |
// MARK: - APIs | |
extension ViewController { | |
func getCountryDetails(countryCode: String) { | |
LearningGraphQLAPI.shared.getCountryDetails(countryCode: countryCode).onSuccess { result in | |
if let data = result.data { | |
dump(data.country) // your result from backend | |
} else if let graphQLError = result.errors { | |
dump(graphQLError) | |
// error of graphQL | |
} | |
}.onFailure { _ in | |
// Here your internet connection error or something technical reason failure | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment