Skip to content

Commit b386f7a

Browse files
authored
Merge pull request #2 from chrislconover/session_delegate_support
allows HTTPNetworkTransport to take URLSession instance This brings apollographql#265 into our fork. We need this capability so we can handle the session's `URLAuthenticationChallenge`.
2 parents b77eddc + b4063ff commit b386f7a

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Sources/Apollo/HTTPNetworkTransport.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,20 @@ public class HTTPNetworkTransport: NetworkTransport {
7272
/// - url: The URL of a GraphQL server to connect to.
7373
/// - configuration: A session configuration used to configure the session. Defaults to `URLSessionConfiguration.default`.
7474
/// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.
75-
public init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) {
75+
public convenience init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) {
76+
self.init(url: url, session: URLSession(configuration: configuration),
77+
sendOperationIdentifiers: sendOperationIdentifiers)
78+
}
79+
80+
/// Creates a network transport with the specified server URL and session.
81+
///
82+
/// - Parameters:
83+
/// - url: The URL of a GraphQL server to connect to.
84+
/// - session: An URLSession instance to be used for ensuing operations.
85+
/// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.
86+
public init(url: URL, session: URLSession, sendOperationIdentifiers: Bool = false) {
7687
self.url = url
77-
self.session = URLSession(configuration: configuration)
88+
self.session = session
7889
self.sendOperationIdentifiers = sendOperationIdentifiers
7990
}
8091

0 commit comments

Comments
 (0)