Definition

Apollo Client is a GraphQL client library for iOS that enables executing GraphQL operations and mapping responses to strongly typed Swift models.


Core Concept

Apollo acts as the bridge between the iOS app and a GraphQL server by:


Key Components


Basic Setup

import Apollo

let apollo = ApolloClient(url: URL(string: "<https://countries.trevorblades.com/>")!)

Executing a Query

apollo.fetch(query: GetCountriesQuery()) { result in
    switch result {
    case .success(let graphQLResult):
        print(graphQLResult.data?.countries)
    case .failure(let error):
        print(error)
    }
}