Swiftpack.co - joel-perry/ApolloCombine as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by joel-perry.
joel-perry/ApolloCombine 0.7.0
A collection of Combine publishers for the Apollo iOS client
⭐️ 82
🕓 3 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/joel-perry/ApolloCombine.git", from: "0.7.0")


GitHub release (latest SemVer) Swift Package Manager Compatible Cocoapods GitHub

A collection of Combine publishers for the Apollo iOS client.


The extension to ApolloClientProtocol (in the aptly named ApolloClientExtensions) includes methods whose inputs mirror the existing ApolloClientProtocol operation methods. Instead of including a result handler, though, these methods return Combine publishers that deliver the results of the operation to subscribers.

When cancel() is invoked on a subscription, the underlying Apollo operation is also cancelled.

fetchPublisher, performPublisher, uploadPublisher, and clearCachePublisher will send a completion when the operation has completed.

import ApolloCombine

let client = ApolloClient(...)

let fetchSubscription = client.fetchPublisher(query: MyQuery(), cachePolicy: .fetchIgnoringCacheData)
  .sink(receiveCompletion: { completion in
    // handle .finished or .failure 
    }, receiveValue: { graphQLResult in
      // handle returned fetch data      

// Cancelling the Combine subscription will also cancel the underlying Apollo operation

watchPublisher and subscribePublisher will not send a completion, instead delivering data and errors as the value of the subscription. This allows these operations to remain open after an error has been encountered. As such, it is important to explicitly cancel these subscriptions when you are done with them to avoid memory leaks.

import ApolloCombine

let client = ApolloClient(...)

let watchSubscription = client.watchPublisher(query: MyQuery())
  .sink(receiveValue: { operationResult in
    switch operationResult {
    case .success(let graphQLResult):
      // handle returned data
    case .failure(let error): 
      // handle error     

// Don't forget to cancel when you're done


Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Use Xcode’s Swift Packages option, which is located within the File menu.


ApolloCombine is available through CocoaPods. To install it, simply add the following line in your Podfile

pod 'ApolloCombine'


ApolloCombine is released under the MIT license. See LICENSE for details.


Stars: 82
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

3 weeks ago
  • Updated method signatures to match current Apollo operation signatures, specifically the addition of a context parameter to all calls. This parameter was added in v1.5.0 of the Apollo iOS client, so dependencies have been changed to reflect this. Fixes #15

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics