Skip to content

Commit

Permalink
Merge pull request #2 from chrislconover/session_delegate_support
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
GevaZeichner authored Jul 18, 2019
2 parents b77eddc + b4063ff commit b386f7a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Sources/Apollo/HTTPNetworkTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,20 @@ public class HTTPNetworkTransport: NetworkTransport {
/// - url: The URL of a GraphQL server to connect to.
/// - configuration: A session configuration used to configure the session. Defaults to `URLSessionConfiguration.default`.
/// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.
public init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) {
public convenience init(url: URL, configuration: URLSessionConfiguration = URLSessionConfiguration.default, sendOperationIdentifiers: Bool = false) {
self.init(url: url, session: URLSession(configuration: configuration),
sendOperationIdentifiers: sendOperationIdentifiers)
}

/// Creates a network transport with the specified server URL and session.
///
/// - Parameters:
/// - url: The URL of a GraphQL server to connect to.
/// - session: An URLSession instance to be used for ensuing operations.
/// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.
public init(url: URL, session: URLSession, sendOperationIdentifiers: Bool = false) {
self.url = url
self.session = URLSession(configuration: configuration)
self.session = session
self.sendOperationIdentifiers = sendOperationIdentifiers
}

Expand Down

0 comments on commit b386f7a

Please sign in to comment.