Skip to content

Commit cbb9a36

Browse files
Merge pull request #1386 from apollographql/betas/networking-stack
Networking Beta
2 parents 7dbfcd4 + 1fc2498 commit cbb9a36

146 files changed

Lines changed: 5613 additions & 2851 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Apollo.xcodeproj/project.pbxproj

Lines changed: 174 additions & 29 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
# Change log
22

3+
## v0.34.0-rc.2
4+
5+
Networking Stack, Release Candidate
6+
7+
- 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))
8+
- 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))
9+
- 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))
10+
11+
## v0.34.0-rc.1
12+
13+
Networking Stack, Release Candidate
14+
15+
- Added some final tweaks:
16+
- Updated `ApolloStore` to take a default cache of the `InMemoryNormalizedCache`.
17+
- Updated LegacyInterceptorProvider to take a default store of the `ApolloStore` with that default cache.
18+
- Added a method to `InterceptorProvider` to provide an error interceptor, along with a default implementation that returns `nil`.
19+
- Updated `JSONRequest` to be open so it can be subclassed.
20+
21+
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)
22+
23+
## v0.34.0-beta2
24+
25+
Networking Stack, Beta 2
26+
27+
- Merges `0.33.0` changes into the networking stack for Swift 5.3 and Xcode 12.
28+
329
## v0.33.0
430
- Adds support for Xcode 12 and Swift 5.3. ([#1280](https://github.com/apollographql/apollo-ios/pull/1280))
531
- 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`)
632

33+
### 0.33.0-beta1
34+
35+
Networking Stack, Beta 1
36+
37+
- **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))
38+
739
## v0.32.1
840
- Improves invalidation of a `URLSesionClient` to include cancellation of in-flight operations. ([#1376](https://github.com/apollographql/apollo-ios/issues/1376))
941

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CURRENT_PROJECT_VERSION = 0.33.0
1+
CURRENT_PROJECT_VERSION = 0.34.0

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ let package = Package(
103103
.testTarget(
104104
name: "ApolloCodegenTests",
105105
dependencies: [
106+
"ApolloTestSupport",
106107
"ApolloCodegenLib"
107108
]),
108109
.testTarget(

Playgrounds/ApolloMacPlayground.playground/Pages/SQLiteCache.xcplaygroundpage/Contents.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import PlaygroundSupport
66

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

9-
//: First, you'll need to set up a network transport, since you will also need that to set up the client:
10-
let serverURL = URL(string: "http://localhost:8080/graphql")!
11-
let networkTransport = HTTPNetworkTransport(url: serverURL)
12-
139
//: 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):
1410
import ApolloSQLite
1511

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

25+
//: Next, you'll need to set up a network transport, since you will also need that to set up the client:
26+
let serverURL = URL(string: "http://localhost:8080/graphql")!
27+
let networkTransport = RequestChainNetworkTransport(interceptorProvider: LegacyInterceptorProvider(store: store), endpointURL: serverURL)
28+
2929
//: Finally, pass that into your `ApolloClient` initializer, and you're now set up to use the SQLite cache for persistent storage:
3030
let apolloClient = ApolloClient(networkTransport: networkTransport, store: store)
3131

32-
33-
//: Now, let's test
32+
//: Now, let's test it out against the Star Wars API!
3433
import StarWarsAPI
34+
3535
let query = HeroDetailsQuery(episode: .newhope)
3636
apolloClient.fetch(query: query) { result in
3737
// This is the outer Result, which has either a `GraphQLResult` or an `Error`

Playgrounds/ApolloMacPlayground.playground/Pages/Subscriptions.xcplaygroundpage/Contents.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Your web backend must declare support for subscriptions in the Schema just like
1717

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

20-
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.
20+
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.
2121

2222
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.
2323
*/
2424

25-
//:First, setup the `HTTPNetworkTransport`:
25+
//:First, setup the `RequestChainNetworkTransport` that will handle your HTTP requests:
2626

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

3030
//: 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:
3131

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

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

37-
let splitTransport = SplitNetworkTransport(httpNetworkTransport: normalTransport, webSocketNetworkTransport: webSocketTransport)
37+
let splitTransport = SplitNetworkTransport(uploadingNetworkTransport: normalTransport, webSocketNetworkTransport: webSocketTransport)
3838

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

0 commit comments

Comments
 (0)