Skip to content

Commit

Permalink
Merge pull request #1386 from apollographql/betas/networking-stack
Browse files Browse the repository at this point in the history
Networking Beta
  • Loading branch information
designatednerd authored Sep 29, 2020
2 parents 7dbfcd4 + 1fc2498 commit cbb9a36
Show file tree
Hide file tree
Showing 146 changed files with 5,613 additions and 2,851 deletions.
203 changes: 174 additions & 29 deletions Apollo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
# Change log

## v0.34.0-rc.2

Networking Stack, Release Candidate

- Made `RequestChainNetworkTransport` subclassable and changed two methods to be `open` so they can be subclassed in order to facilitate using subclasses of `HTTPRequest` when needed. ([#1405](https://github.com/apollographql/apollo-ios/pull/1405))
- Made numerous improvements to creating upload requests - all upload request setup is now happening through the `UploadRequest` class, which is now `open` for your subclassing funtimes. ([#1405](https://github.com/apollographql/apollo-ios/pull/1405))
- Renamed `RequestCreator` to `RequestBodyCreator` to more accurately reflect what it's doing (particularly in light of the fact that we didn't have a `Request` in the old networking stack, and now we do), and renamed associated properties and parameters. ([#1405](https://github.com/apollographql/apollo-ios/pull/1405))

## v0.34.0-rc.1

Networking Stack, Release Candidate

- Added some final tweaks:
- Updated `ApolloStore` to take a default cache of the `InMemoryNormalizedCache`.
- Updated LegacyInterceptorProvider to take a default store of the `ApolloStore` with that default cache.
- Added a method to `InterceptorProvider` to provide an error interceptor, along with a default implementation that returns `nil`.
- Updated `JSONRequest` to be open so it can be subclassed.

This is now at the point where if there are no further major bugs, I'd like to release this - get your bugs in ASAP! ([#1399](https://github.com/apollographql/apollo-ios/pull/1399)

## v0.34.0-beta2

Networking Stack, Beta 2

- Merges `0.33.0` changes into the networking stack for Swift 5.3 and Xcode 12.

## v0.33.0
- Adds support for Xcode 12 and Swift 5.3. ([#1280](https://github.com/apollographql/apollo-ios/pull/1280))
- Adds workaround script for Carthage support in Xcode 12. Please see [Carthage-3019](https://github.com/Carthage/Carthage/issues/3019) for details. TL;DR: cd into `[YourProject]/Carthage/Checkouts/apollo-ios/scripts` and then run `./carthage-build-workaround.sh` to actually get Carthage builds that work. (#yolo committed to `main`)

### 0.33.0-beta1

Networking Stack, Beta 1

- **SPECTACULARLY BREAKING**: The networking stack for HTTP requests has been completely rewritten. This is described in great detail in the [RFC for the networking changes](https://github.com/apollographql/apollo-ios/issues/1340), as well as the [updated documentation for Advanced Client Creation](https://deploy-preview-1386--apollo-ios-docs.netlify.app/docs/ios/initialization/#advanced-client-creation). Please, please, please file bugs or requests for clarification of the docs as soon as possible. Note that all changes until the networking stack comes out of beta will live on the `betas/networking-stack` branch. ([#1341](https://github.com/apollographql/apollo-ios/issues/1341))

## v0.32.1
- Improves invalidation of a `URLSesionClient` to include cancellation of in-flight operations. ([#1376](https://github.com/apollographql/apollo-ios/issues/1376))

Expand Down
2 changes: 1 addition & 1 deletion Configuration/Shared/Project-Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 0.33.0
CURRENT_PROJECT_VERSION = 0.34.0
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ let package = Package(
.testTarget(
name: "ApolloCodegenTests",
dependencies: [
"ApolloTestSupport",
"ApolloCodegenLib"
]),
.testTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import PlaygroundSupport

//: # Setting up a client with a SQLite cache

//: First, you'll need to set up a network transport, since you will also need that to set up the client:
let serverURL = URL(string: "http://localhost:8080/graphql")!
let networkTransport = HTTPNetworkTransport(url: serverURL)

//: You'll need to make sure you import the ApolloSQLite library IF you are not using CocoaPods (CocoaPods will automatically flatten everything down to a single Apollo import):
import ApolloSQLite

Expand All @@ -26,12 +22,16 @@ let sqliteCache = try SQLiteNormalizedCache(fileURL: sqliteFileURL)
//: And then instantiate an instance of `ApolloStore` with the cache you've just created:
let store = ApolloStore(cache: sqliteCache)

//: Next, you'll need to set up a network transport, since you will also need that to set up the client:
let serverURL = URL(string: "http://localhost:8080/graphql")!
let networkTransport = RequestChainNetworkTransport(interceptorProvider: LegacyInterceptorProvider(store: store), endpointURL: serverURL)

//: Finally, pass that into your `ApolloClient` initializer, and you're now set up to use the SQLite cache for persistent storage:
let apolloClient = ApolloClient(networkTransport: networkTransport, store: store)


//: Now, let's test
//: Now, let's test it out against the Star Wars API!
import StarWarsAPI

let query = HeroDetailsQuery(episode: .newhope)
apolloClient.fetch(query: query) { result in
// This is the outer Result, which has either a `GraphQLResult` or an `Error`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Your web backend must declare support for subscriptions in the Schema just like

To use subscriptions, you need to have a `NetworkTransport` implementation which supports them. Fortunately, with the `ApolloWebSocket` package, there are two!

The first is the `WebSocketTransport`, which works with the web socket, and the second is the `SplitNetworkTransport`, which uses a web socket for subscriptions but a normal `HTTPNetworkTransport` for everything else.
The first is the `WebSocketTransport`, which works with the web socket, and the second is the `SplitNetworkTransport`, which uses a web socket for subscriptions but a normal `RequestChainNetworkTransport` for everything else.

In this instance, we'll use a `SplitNetworkTransport` since we want to demonstrate subscribing to changes, but we need to also be able to send changes for that subscription to come through.
*/

//:First, setup the `HTTPNetworkTransport`:
//:First, setup the `RequestChainNetworkTransport` that will handle your HTTP requests:

let url = URL(string: "http://localhost:8080/graphql")!
let normalTransport = HTTPNetworkTransport(url: url)
let normalTransport = RequestChainNetworkTransport(interceptorProvider: LegacyInterceptorProvider(), endpointURL: url)

//: Next, set up the `WebSocketTransport` to talk to the websocket endpoint. Note that this may take a different URL, sometimes with a `ws` prefix, than your normal http endpoint:

Expand All @@ -34,7 +34,7 @@ let webSocketTransport = WebSocketTransport(request: URLRequest(url: webSocketUR

//: Then, set up the split transport with the two transports you've just created:

let splitTransport = SplitNetworkTransport(httpNetworkTransport: normalTransport, webSocketNetworkTransport: webSocketTransport)
let splitTransport = SplitNetworkTransport(uploadingNetworkTransport: normalTransport, webSocketNetworkTransport: webSocketTransport)

//: Finally, instantiate your client with the split transport:

Expand Down
Loading

0 comments on commit cbb9a36

Please sign in to comment.