Skip to content

Commit

Permalink
Compatibility fixes for 1.9.1 (#290)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeff Johnston <hishma@users.noreply.github.com>
  • Loading branch information
AnthonyMDev and hishma committed Mar 8, 2024
1 parent a86c99a commit 671ce5f
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 13 deletions.
24 changes: 12 additions & 12 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlCatchException.git",
"state" : {
"revision" : "3b123999de19bf04905bc1dfdb76f817b0f2cc00",
"version" : "2.1.2"
"revision" : "3ef6999c73b6938cc0da422f2c912d0158abb0a0",
"version" : "2.2.0"
}
},
{
"identity" : "cwlpreconditiontesting",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state" : {
"revision" : "dc9af4781f2afdd1e68e90f80b8603be73ea7abc",
"version" : "2.2.0"
"revision" : "2ef56b2caf25f55fa7eef8784c30d5a767550f54",
"version" : "2.2.1"
}
},
{
Expand All @@ -32,35 +32,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "c1f3dd66222d5e7a1a20afc237f7e7bc432c564f",
"version" : "13.2.0"
"revision" : "efe11bbca024b57115260709b5c05e01131470d0",
"version" : "13.2.1"
}
},
{
"identity" : "sqlite.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stephencelis/SQLite.swift.git",
"state" : {
"revision" : "7a2e3cd27de56f6d396e84f63beefd0267b55ccb",
"version" : "0.14.1"
"revision" : "e78ae0220e17525a15ac68c697a155eb7a672a8e",
"version" : "0.15.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192",
"version" : "1.0.6"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
}
],
Expand Down
1 change: 1 addition & 0 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let project = Project(
organizationName: "apollographql",
packages: [
.package(url: "https://github.com/Quick/Nimble.git", from: "13.2.0"),
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.1"),
.package(path: "apollo-ios"),
.package(path: "apollo-ios-codegen"),
.package(path: "apollo-ios-pagination"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ extension Target {
.target(name: ApolloTarget.starWarsAPI.name),
.target(name: ApolloTarget.uploadAPI.name),
.package(product: "Apollo"),
.package(product: "ApolloSQLite"),
.package(product: "ApolloWebSocket"),
.package(product: "ApolloTestSupport"),
.package(product: "SQLite"),
.package(product: "Nimble")
],
settings: .forTarget(target)
Expand Down
57 changes: 57 additions & 0 deletions apollo-ios/Sources/Apollo/ApolloClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,60 @@ public protocol ApolloClientProtocol: AnyObject {
queue: DispatchQueue,
resultHandler: @escaping GraphQLResultHandler<Subscription.Data>) -> Cancellable
}

// MARK: - Backwards Compatibilty Extension

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.
///
/// - Parameters:
/// - query: The query to fetch.
/// - cachePolicy: A cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache.
/// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - resultHandler: [optional] A closure that is called when query results are available or when an error occurs.
/// - Returns: An object that can be used to cancel an in progress fetch.
func fetch<Query: GraphQLQuery>(
query: Query,
cachePolicy: CachePolicy,
context: RequestContext?,
queue: DispatchQueue,
resultHandler: GraphQLResultHandler<Query.Data>?
) -> Cancellable {
self.fetch(
query: query,
cachePolicy: cachePolicy,
contextIdentifier: nil,
context: context,
queue: queue,
resultHandler: resultHandler
)
}

/// Performs a mutation by sending it to the server.
///
/// - Parameters:
/// - mutation: The mutation to perform.
/// - publishResultToStore: If `true`, this will publish the result returned from the operation to the cache store. Default is `true`.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - resultHandler: An optional closure that is called when mutation results are available or when an error occurs.
/// - Returns: An object that can be used to cancel an in progress mutation.
func perform<Mutation: GraphQLMutation>(
mutation: Mutation,
publishResultToStore: Bool,
context: RequestContext?,
queue: DispatchQueue,
resultHandler: GraphQLResultHandler<Mutation.Data>?
) -> Cancellable {
self.perform(
mutation: mutation,
publishResultToStore: publishResultToStore,
contextIdentifier: nil,
context: context,
queue: queue,
resultHandler: resultHandler
)
}
}
14 changes: 13 additions & 1 deletion apollo-ios/Sources/Apollo/URLSessionClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,19 @@ open class URLSessionClient: NSObject, URLSessionDelegate, URLSessionTaskDelegat

return task
}


@discardableResult
open func sendRequest(_ request: URLRequest,
rawTaskCompletionHandler: RawCompletion? = nil,
completion: @escaping Completion) -> URLSessionTask {
sendRequest(
request,
taskDescription: nil,
rawTaskCompletionHandler: nil,
completion: completion
)
}

/// Cancels a given task and clears out its underlying data.
///
/// NOTE: You will not receive any kind of "This was cancelled" error when this is called.
Expand Down

0 comments on commit 671ce5f

Please sign in to comment.