Created
March 6, 2022 11:20
-
-
Save chandan-0/a0877d8e11b43ce8839572a53078afa5 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
// | |
// LearningGraphQLAPI.swift | |
// Learning GraphQL | |
// | |
// Created by Chandan on 06/03/22. | |
// | |
import Foundation | |
import Apollo | |
import BrightFutures | |
class LearningGraphQLAPI { | |
static let shared = LearningGraphQLAPI() | |
// Your get country details Query ready | |
func getCountryDetails(countryCode: String) -> Future<GraphQLResult<GetCountryQuery.Data>, Error> { | |
let promice = Promise<GraphQLResult<GetCountryQuery.Data>, Error>() | |
Network.shared.apollo.fetch(query: GetCountryQuery(id: countryCode)) { response in | |
switch response.result { | |
case .success(let graphQlResult): | |
promice.success(graphQlResult) | |
case .failure(let error): | |
promice.failure(error) | |
} | |
} | |
return promice.future | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment