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

Swap out session configuration for URLSession #699

Merged
merged 4 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ cache:
- ../starwars-server

before_install:
- nvm install 8
- nvm alias default 8
- nvm install 10
- nvm alias default 10
- (./scripts/install-or-update-starwars-server.sh)
- (cd ../starwars-server && npm start) &
- npm install -g apollo
Expand Down
6 changes: 3 additions & 3 deletions Sources/Apollo/HTTPNetworkTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ public class HTTPNetworkTransport {
///
/// - Parameters:
/// - url: The URL of a GraphQL server to connect to.
/// - configuration: A session configuration used to configure the session. Defaults to `URLSessionConfiguration.default`.
/// - session: The URLSession to use. Defaults to `URLSession.shared`,
/// - sendOperationIdentifiers: Whether to send operation identifiers rather than full operation text, for use with servers that support query persistence. Defaults to false.
/// - useGETForQueries: If query operation should be sent using GET instead of POST. Defaults to false.
/// - delegate: [Optional] A delegate which can conform to any or all of `HTTPNetworkTransportPreflightDelegate`, `HTTPNetworkTransportTaskCompletedDelegate`, and `HTTPNetworkTransportRetryDelegate`. Defaults to nil.
public init(url: URL,
configuration: URLSessionConfiguration = .default,
session: URLSession = .shared,
sendOperationIdentifiers: Bool = false,
useGETForQueries: Bool = false,
delegate: HTTPNetworkTransportDelegate? = nil) {
self.url = url
self.session = URLSession(configuration: configuration)
self.session = session
self.sendOperationIdentifiers = sendOperationIdentifiers
self.useGETForQueries = useGETForQueries
self.delegate = delegate
Expand Down
2 changes: 1 addition & 1 deletion docs/source/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The available implementations are:

The initializer for `HTTPNetworkTransport` has several properties which can allow you to get better information and finer-grained control of your HTTP requests and responses:

- `configuration` allows you to pass in a custom `URLSessionConfiguration` to set up anything which needs to be done for every single request without alteration. This defaults to `URLSessionConfiguration.default`.
- `session` allows you to pass in a custom `URLSession` to set up anything which needs to be done for every single request without alteration. This defaults to `URLSession.shared`.
- `sendOperationIdentifiers` allows you send operation identifiers along with your requests. **NOTE:** To send operation identifiers, Apollo types must be generated with `operationIdentifier`s or sending data will crash. Due to this restriction, this option defaults to `false`.
- `useGETForQueries` sends all requests of `query` type using `GET` instead of `POST`. This defaults to `false` to preserve existing behavior in older versions of the client.
- `delegate` Can conform to one or many of several sub-protocols for `HTTPNetworkTransportDelegate`, detailed below.
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-or-update-starwars-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cd $(dirname "$0")/../..

git -C starwars-server pull || git clone https://github.com/apollostack/starwars-server
git -C starwars-server pull || git clone https://github.com/apollographql/starwars-server

cd starwars-server

Expand Down