Swiftpack.co - Package - joel-perry/ApolloCombine

ApolloCombine

GitHub release (latest SemVer) Swift Package Manager Compatible GitHub

A collection of Combine publishers for the Apollo iOS client.

Versions

The Apollo iOS client uses a new networking stack beginning with 0.34.0-beta2, so the version of ApolloCombine you should use depends on whether you have adopted this change.

  • Use ApolloCombine release 0.2.2 if you have not upgraded to the new networking stack
  • Use ApolloCombine release 0.3.0 and above if you are using the new networking stack

Usage

The extension to ApolloClient (in the aptly named ApolloClientExtensions) includes methods whose inputs mirror the existing ApolloClient 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, and uploadPublisher subscriptions will send .finished completions whey they are done.

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
fetchSubscription.cancel()

Installation

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.

License

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

Github

link
Stars: 15

Used By

Total: 0

Releases

- 2020-09-22 22:00:23

BREAKING: The Apollo iOS client introduced a new networking stack in 0.34.0-beta2. This version of ApolloCombine has been updated to interface with the new method signatures. Only use this version if you have adopted the new networking stack. Otherwise, stick with ApolloCombine 0.2.2.

- 2020-09-22 13:42:13

The Apollo iOS client uses a new networking stack beginning with 0.34.0-rc.1. This is the last release of ApolloCombine that will be compatible with the old networking stack. The dependency requirement has been updated accordingly.

- 2020-09-13 14:45:52

Quick fix for watchOS:

  • Remove test target from Package.swift

Changes in 0.2.0:

  • Add publisher for clearCache() (https://github.com/joel-perry/ApolloCombine/pull/2)
  • Add tvOS and watchOS support in Package.swift

- 2020-09-12 14:26:05

Add publisher for clearCache() (https://github.com/joel-perry/ApolloCombine/pull/2) Add tvOS and watchOS support in Package.swift

- 2020-08-31 13:08:27

Add macOS support in Package.swift (https://github.com/joel-perry/ApolloCombine/pull/1)

- 2020-06-29 13:18:42

Initial release