Skip to content

Instantly share code, notes, and snippets.

@chandan-0
Created March 6, 2022 11:53
Show Gist options
  • Save chandan-0/9a8934cbc7cd53ff3cc8b1fc73479e25 to your computer and use it in GitHub Desktop.
Save chandan-0/9a8934cbc7cd53ff3cc8b1fc73479e25 to your computer and use it in GitHub Desktop.
//
// 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