Skip to content

Commit

Permalink
Resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-perry committed Sep 22, 2020
2 parents b349b60 + 24bd8bc commit bbb4d13
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
],
dependencies: [
.package(name: "Apollo",
url: "https://github.com/apollographql/apollo-ios.git", "0.28.0"..<"0.34.0")
url: "https://github.com/apollographql/apollo-ios.git", from: "0.34.0-beta2")
],
targets: [
.target(name: "ApolloCombine", dependencies: [.product(name: "Apollo", package: "Apollo")])
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

A collection of Combine publishers for the [Apollo iOS client](https://github.com/apollographql/apollo-ios).

## A note about the Apollo iOS client beta
The Apollo iOS client is undergoing some large changes in the networking stack. Consequently, ApolloCombine will need some reworking to interface correctly with the new client. I have started a branch called 'apollo-beta' to perform these changes and will do my best to keep it in synch with the client betas.
## 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.
Expand Down
15 changes: 6 additions & 9 deletions Sources/ApolloCombine/ApolloClientExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public extension ApolloClient {
/// - Returns: A publisher that delivers results from the fetch operaion.
func fetchPublisher<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy = .returnCacheDataElseFetch,
context: UnsafeMutableRawPointer? = nil,
contextIdentifier: UUID? = nil,
queue: DispatchQueue = .main) -> Publishers.ApolloFetch<Query> {
let config = Publishers.ApolloFetchConfiguration(client: self, query: query, cachePolicy: cachePolicy, context: context, queue: queue)
let config = Publishers.ApolloFetchConfiguration(client: self, query: query, cachePolicy: cachePolicy, contextIdentifier: contextIdentifier, queue: queue)
return Publishers.ApolloFetch(with: config)
}

Expand All @@ -28,9 +28,8 @@ public extension ApolloClient {
/// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue.
/// - Returns: A publisher that delivers results from the perform operaion.
func performPublisher<Mutation: GraphQLMutation>(mutation: Mutation,
context: UnsafeMutableRawPointer? = nil,
queue: DispatchQueue = .main) -> Publishers.ApolloPerform<Mutation> {
let config = Publishers.ApolloPerformConfiguration(client: self, mutation: mutation, context: context, queue: queue)
let config = Publishers.ApolloPerformConfiguration(client: self, mutation: mutation, queue: queue)
return Publishers.ApolloPerform(with: config)
}

Expand All @@ -43,10 +42,9 @@ public extension ApolloClient {
/// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue.
/// - Returns: A publisher that delivers results from the upload operaion.
func uploadPublisher<Operation: GraphQLOperation>(operation: Operation,
context: UnsafeMutableRawPointer? = nil,
files: [GraphQLFile],
queue: DispatchQueue = .main) -> Publishers.ApolloUpload<Operation> {
let config = Publishers.ApolloUploadConfiguration(client: self, operation: operation, context: context, files: files, queue: queue)
let config = Publishers.ApolloUploadConfiguration(client: self, operation: operation, files: files, queue: queue)
return Publishers.ApolloUpload(with: config)
}

Expand All @@ -58,9 +56,8 @@ public extension ApolloClient {
/// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue.
/// - Returns: A publisher that delivers results from the watch operaion.
func watchPublisher<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy = .returnCacheDataElseFetch,
queue: DispatchQueue = .main) -> Publishers.ApolloWatch<Query> {
let config = Publishers.ApolloWatchConfiguration(client: self, query: query, cachePolicy: cachePolicy, queue: queue)
cachePolicy: CachePolicy = .returnCacheDataElseFetch) -> Publishers.ApolloWatch<Query> {
let config = Publishers.ApolloWatchConfiguration(client: self, query: query, cachePolicy: cachePolicy)
return Publishers.ApolloWatch(with: config)
}

Expand Down
12 changes: 3 additions & 9 deletions Sources/ApolloCombine/PublishersExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public extension Publishers {
let client: ApolloClient
let query: Query
let cachePolicy: CachePolicy
let context: UnsafeMutableRawPointer?
let contextIdentifier: UUID?
let queue: DispatchQueue
}

Expand All @@ -48,7 +48,7 @@ public extension Publishers {
func request(_ demand: Subscribers.Demand) {
task = configuration.client.fetch(query: configuration.query,
cachePolicy: configuration.cachePolicy,
context: configuration.context,
contextIdentifier: configuration.contextIdentifier,
queue: configuration.queue)
{ [weak self] result in
switch result {
Expand Down Expand Up @@ -93,7 +93,6 @@ public extension Publishers {
struct ApolloPerformConfiguration<Mutation: GraphQLMutation> {
let client: ApolloClient
let mutation: Mutation
let context: UnsafeMutableRawPointer?
let queue: DispatchQueue
}

Expand All @@ -110,7 +109,6 @@ public extension Publishers {

func request(_ demand: Subscribers.Demand) {
task = configuration.client.perform(mutation: configuration.mutation,
context: configuration.context,
queue: configuration.queue)
{ [weak self] result in
switch result {
Expand Down Expand Up @@ -151,7 +149,6 @@ public extension Publishers {
struct ApolloUploadConfiguration<Operation: GraphQLOperation> {
let client: ApolloClient
let operation: Operation
let context: UnsafeMutableRawPointer?
let files: [GraphQLFile]
let queue: DispatchQueue
}
Expand All @@ -169,7 +166,6 @@ public extension Publishers {

func request(_ demand: Subscribers.Demand) {
task = configuration.client.upload(operation: configuration.operation,
context: configuration.context,
files: configuration.files,
queue: configuration.queue)
{ [weak self] result in
Expand Down Expand Up @@ -212,7 +208,6 @@ public extension Publishers {
let client: ApolloClient
let query: Query
let cachePolicy: CachePolicy
let queue: DispatchQueue
}

private final class ApolloWatchSubscription<S: Subscriber, Query: GraphQLQuery>: Subscription
Expand All @@ -228,8 +223,7 @@ public extension Publishers {

func request(_ demand: Subscribers.Demand) {
task = configuration.client.watch(query: configuration.query,
cachePolicy: configuration.cachePolicy,
queue: configuration.queue)
cachePolicy: configuration.cachePolicy)
{ [weak self] result in
switch result {
case .success(let data):
Expand Down

0 comments on commit bbb4d13

Please sign in to comment.