Skip to content

Commit

Permalink
replaced ApolloClient references with ApolloClientProtocol, added mis…
Browse files Browse the repository at this point in the history
…sing publishResultToStore property on perform method.
  • Loading branch information
Tiziano Coroneo committed Apr 2, 2021
1 parent c65fd1a commit 1fa37f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Sources/ApolloCombine/ApolloClientExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Apollo
import Combine
import Foundation

public extension ApolloClient {
public extension ApolloClientProtocol {

/// Fetches a query from the server or from the local cache, depending on the current contents of the cache and the specified cache policy.
///
Expand All @@ -28,8 +28,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 perform operaion.
func performPublisher<Mutation: GraphQLMutation>(mutation: Mutation,
publishResultToStore: Bool = true,
queue: DispatchQueue = .main) -> Publishers.ApolloPerform<Mutation> {
let config = Publishers.ApolloPerformConfiguration(client: self, mutation: mutation, queue: queue)
let config = Publishers.ApolloPerformConfiguration(client: self, mutation: mutation, publishResultToStore: publishResultToStore, queue: queue)
return Publishers.ApolloPerform(with: config)
}

Expand Down
14 changes: 8 additions & 6 deletions Sources/ApolloCombine/PublishersExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension Publishers {
}

struct ApolloFetchConfiguration<Query: GraphQLQuery> {
let client: ApolloClient
let client: ApolloClientProtocol
let query: Query
let cachePolicy: CachePolicy
let contextIdentifier: UUID?
Expand Down Expand Up @@ -91,8 +91,9 @@ public extension Publishers {
}

struct ApolloPerformConfiguration<Mutation: GraphQLMutation> {
let client: ApolloClient
let client: ApolloClientProtocol
let mutation: Mutation
let publishResultToStore: Bool
let queue: DispatchQueue
}

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

func request(_ demand: Subscribers.Demand) {
task = configuration.client.perform(mutation: configuration.mutation,
publishResultToStore: configuration.publishResultToStore,
queue: configuration.queue)
{ [weak self] result in
switch result {
Expand Down Expand Up @@ -147,7 +149,7 @@ public extension Publishers {
}

struct ApolloUploadConfiguration<Operation: GraphQLOperation> {
let client: ApolloClient
let client: ApolloClientProtocol
let operation: Operation
let files: [GraphQLFile]
let queue: DispatchQueue
Expand Down Expand Up @@ -205,7 +207,7 @@ public extension Publishers {
}

struct ApolloWatchConfiguration<Query: GraphQLQuery> {
let client: ApolloClient
let client: ApolloClientProtocol
let query: Query
let cachePolicy: CachePolicy
}
Expand Down Expand Up @@ -254,7 +256,7 @@ public extension Publishers {
}

struct ApolloSubscribeConfiguration<Subscription: GraphQLSubscription> {
let client: ApolloClient
let client: ApolloClientProtocol
let subscription: Subscription
let queue: DispatchQueue
}
Expand Down Expand Up @@ -303,7 +305,7 @@ public extension Publishers {
}

struct ApolloClearCacheConfiguration {
let client: ApolloClient
let client: ApolloClientProtocol
let queue: DispatchQueue
}

Expand Down

0 comments on commit 1fa37f6

Please sign in to comment.