Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTPNetworkTransport.init to take URLSession instance to allow … #265

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Sources/Apollo/HTTPNetworkTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,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