Skip to content

Instantly share code, notes, and snippets.

@chandan-0
Created April 26, 2022 03:11
Show Gist options
  • Save chandan-0/926a7e49f8fcc755e0a9ba60956bdb12 to your computer and use it in GitHub Desktop.
Save chandan-0/926a7e49f8fcc755e0a9ba60956bdb12 to your computer and use it in GitHub Desktop.
API Call
//
// 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