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 { |
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
func addMeasurement(id: String, measurement: ClientMeasurementRequest) -> Future<GraphQLResult<AddMeasurementMutation.Data>, Error> { | |
let promise = Promise<GraphQLResult<AddMeasurementMutation.Data>, Error>() | |
Network.shared.apollo.perform(mutation: AddMeasurementMutation(client_id: id, measurementsRequest: measurement)) { response in | |
switch response.result { | |
case .success(let graphqlResult): | |
promise.success(graphqlResult) | |
case .failure(let error): | |
promise.failure(error) | |
} | |
} |
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
public final class AddMeasurementMutation: GraphQLMutation { | |
/// The raw GraphQL definition of this operation. | |
public let operationDefinition: String = | |
""" | |
mutation addMeasurement($client_id: String!, $measurementsRequest: ClientMeasurementRequest!) { | |
addMeasurement(client_id: $client_id, measurementsRequest: $measurementsRequest) { | |
__typename | |
id | |
weight | |
weightUnit |
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
mutation addMeasurement($client_id: String!, $measurementsRequest: ClientMeasurementRequest!) { | |
addMeasurement(client_id: $client_id, measurementsRequest: $measurementsRequest) { | |
__typename | |
id | |
weight | |
weightUnit | |
height | |
heightUnit | |
createdAt | |
} |
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
2022-03-06 17:24:57.018472+0530 Learning GraphQL[92954:10939120] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics | |
▿ Optional(Learning_GraphQL.GetCountryQuery.Data.Country(resultMap: ["phone": Optional("91"), "__typename": Optional("Country"), "native": Optional("भारत"), "capital": Optional("New Delhi"), "name": Optional("India"), "code": Optional("IN"), "currency": Optional("INR")])) | |
▿ some: Learning_GraphQL.GetCountryQuery.Data.Country | |
▿ resultMap: 7 key/value pairs | |
▿ (2 elements) | |
- key: "phone" | |
▿ value: Optional("91") | |
- some: "91" | |
▿ (2 elements) | |
- key: "__typename" |
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 { |
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 |
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
query getCountry($id: ID!){ | |
country(code: $id) { | |
code | |
name | |
native | |
phone | |
capital | |
currency | |
} | |
} |
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
import Foundation | |
import Apollo | |
class Network { | |
static let shared = Network() | |
var apollo: ApolloClient { | |
// The cache is necessary to set up the store, which we're going to hand to the provider | |
let cache = InMemoryNormalizedCache() | |
let store = ApolloStore(cache: cache) |