Created
April 26, 2022 03:11
-
-
Save chandan-0/926a7e49f8fcc755e0a9ba60956bdb12 to your computer and use it in GitHub Desktop.
API Call
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() | |
addMeasurement(clientId: "Client ID", request: request) // the request is the data which wants to update in the server. | |
} | |
} | |
// MARK: - APIs | |
extension ViewController { | |
func addMeasurement(clientId: String, request: ClientMeasurementRequest) { | |
LearningGraphQLAPI.shared.adMeasurement(id: clientId, measurement: request).onSuccess { [weak self] result in | |
if let data = result.data { | |
// RESULT From backend | |
} else if let error = result.errors { | |
// GraphQL Error | |
} | |
}.onFailure { _ in | |
// Technical issue error | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment