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

Networking Beta #1386

Merged
merged 153 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
505df39
add noodling from scratch project
designatednerd Apr 29, 2020
ccf49c8
change generics on the request chain
designatednerd Apr 29, 2020
1d262ae
add interceptor provider protocol and a couple default implementations
designatednerd Apr 30, 2020
58a2b8d
separate out legacy vs codable parsing
designatednerd Apr 30, 2020
c5cd160
bits o'cleanup
designatednerd Jul 14, 2020
7f57d20
Working on legacy request chain...ish
designatednerd Jul 14, 2020
73dc705
add readability extension
designatednerd Jul 14, 2020
eff721a
Move cache policy up to base request type
designatednerd Jul 14, 2020
99b1c8f
start adding legacy cache interceptor
designatednerd Jul 15, 2020
ad892c6
add send for result to mock transport
designatednerd Jul 24, 2020
a63bc5d
use send for result to get an actual result
designatednerd Jul 24, 2020
f573bb8
Break off trying to read from the cache too early
designatednerd Jul 24, 2020
1588e1b
Add some documentation to the request chain
designatednerd Jul 27, 2020
d671cf1
add additional error interceptor so people can examine errors more di…
designatednerd Jul 28, 2020
3d2f0fb
add and test legacy cache write interceptor
designatednerd Jul 28, 2020
e4689a3
move cancellation handling to the chain rather than the individual in…
designatednerd Jul 28, 2020
d834070
rearrange a bunch of stuff and make a few things public
designatednerd Jul 28, 2020
085adc5
add quasi-todos for codable interceptor chain
designatednerd Jul 28, 2020
745d3e5
remove fetch source type since it duplicates data in GraphQLResult
designatednerd Jul 28, 2020
97ce0cc
update a ton of documentation
designatednerd Jul 28, 2020
ba1823f
add ability to specify callback queue and have chain return value as …
designatednerd Jul 28, 2020
c618935
moar docs!
designatednerd Jul 29, 2020
ff4b578
initial stab at an upload request
designatednerd Aug 5, 2020
69ce161
initial stab at an APQ interceptor
designatednerd Aug 5, 2020
e67e29b
Constrain on GraphQLResult<Operation.Data> rather than more generic `…
designatednerd Aug 5, 2020
103cb9c
remove unused error
designatednerd Aug 11, 2020
ac73778
Add APQ interceptor to default interceptors
designatednerd Aug 11, 2020
00beb84
Make sure upload requests are `POST` requests
designatednerd Aug 11, 2020
e970fd8
add `uploadForResult` handling to ApolloClient
designatednerd Aug 11, 2020
27975cf
update upload tests to use new architecture
designatednerd Aug 11, 2020
aeb85cb
make star wars server tests able to use any network transport
designatednerd Aug 11, 2020
77df5ad
add parsing for http network transport in parse for result
designatednerd Aug 11, 2020
9d93367
make sure store can be passed in when creating networking stack
designatednerd Aug 11, 2020
8576947
update websocket transports to use more generic uploading transport
designatednerd Aug 11, 2020
5f64ff7
add and use max retry interceptor
designatednerd Aug 11, 2020
35cfe85
Add tests for request chain with APQs
designatednerd Aug 11, 2020
1af4e90
Update HTTP response to be optional until created.
designatednerd Aug 13, 2020
efd1fec
Actually, data from a GraphQL request should never be nil, so don't a…
designatednerd Aug 13, 2020
9b0718f
Move errors to their specific interceptors so people can tell where t…
designatednerd Aug 13, 2020
68cd516
update todos that need to be resolved before merge to warnings
designatednerd Aug 13, 2020
41467ab
Remove duplicated read interceptor
designatednerd Aug 14, 2020
a4c4a4b
add test URLs to test helpers so we stop having to hard-code URLs all…
designatednerd Aug 14, 2020
a67423e
use mock instead of HTTP network transport for split network transpor…
designatednerd Aug 14, 2020
b1e5f9d
use request chain trainsport for caching roundtrip tests
designatednerd Aug 14, 2020
5a237fa
user request chain transport instead of http transport for non-websoc…
designatednerd Aug 14, 2020
b14027b
make sure you can set client name and client version on request chains
designatednerd Aug 18, 2020
444c465
get rid of separate `sendForResult` etc and centralize on a single `s…
designatednerd Aug 18, 2020
e3f27fc
update mock URL transport to be a subclass of RequestChain transport,…
designatednerd Aug 18, 2020
7a944ed
Make sure we're checking a thread-safe value for the last received re…
designatednerd Aug 18, 2020
3a73b66
Get rid of now-unnecessary fetch query operation and asynchronous ope…
designatednerd Aug 18, 2020
a7f66c3
make sure Apollo Test Support is added to Codegen tests
designatednerd Aug 18, 2020
ce42918
Fix build failures in codegen tests
designatednerd Aug 18, 2020
b946e18
add default cache policy on request chain network transport
designatednerd Aug 18, 2020
1fd913c
switch APQ tests to using Request Chain Network Transport
designatednerd Aug 18, 2020
6808f9f
make APQ tests async to account for request construction being async …
designatednerd Aug 18, 2020
632285b
add check for persisted query retry failure to APQ interceptor
designatednerd Aug 18, 2020
2e99554
move star wars server tests to using request chain transport by default
designatednerd Aug 18, 2020
ace861c
pick fight with future me
designatednerd Aug 18, 2020
660eb0d
update skipped tests in schemes
designatednerd Aug 18, 2020
f92ba25
remove old skipped tests in schemes
designatednerd Aug 18, 2020
594eea2
add inititalizer where data is decodable to graphQL result
designatednerd Aug 18, 2020
5a23ee8
Get rid of old HTTPNetworkTransport
designatednerd Aug 19, 2020
2939afe
return the data that didn't parse when it doesn't parse
designatednerd Aug 19, 2020
d2bf67f
Make sure public interceptors have public initializers
designatednerd Aug 19, 2020
b73084f
add a bunch of tests and test interceptors
designatednerd Aug 19, 2020
3aeb966
Add test to validate empty array of interceptors error
designatednerd Aug 19, 2020
632621f
update request chain to check if there's a result when we run out of …
designatednerd Aug 19, 2020
8f032e8
get rid of now-unnecessary finalizing interceptor
designatednerd Aug 19, 2020
288596f
Update cache write intercetptor to proceed rather than return value s…
designatednerd Aug 19, 2020
2f1b54c
Make sure client gets invalidated on deinit, but only when appropriate.
designatednerd Aug 20, 2020
9cf523d
Add a legacy response property to HTTPResponse to facilitate not havi…
designatednerd Aug 20, 2020
b4e0665
fix whitespace sadness
designatednerd Aug 31, 2020
70a38eb
get rid of now-unused context from client
designatednerd Aug 31, 2020
54bea9d
Make sure watcher is cancelled at the end of the test so it doesn't a…
designatednerd Aug 31, 2020
9e20638
temporarily pass nil for extensinons
designatednerd Aug 31, 2020
e8b777c
update mock network transport to be able to update network body, also…
designatednerd Sep 1, 2020
2665f7e
use marginally slower parsing for initial parse if we're going to the…
designatednerd Sep 2, 2020
a4cb8ba
remove now-unused method
designatednerd Sep 2, 2020
554e659
add workaround for the fact that removing the context means actual fe…
designatednerd Sep 2, 2020
ebcb61a
bump timeout on initial fetch expectation for CI
designatednerd Sep 2, 2020
00e79b5
delete removed tests from list of skipped tests in schemes
designatednerd Sep 3, 2020
1e24f0b
get rid of now-unused queue properties
designatednerd Sep 3, 2020
946ce0e
move queue handling down to the network transport level
designatednerd Sep 3, 2020
1da7651
add docs to request chain and request chain network transport
designatednerd Sep 3, 2020
89bdbc3
cancel watcher at the end of watch query tests
designatednerd Sep 3, 2020
d785898
Document more things!
designatednerd Sep 3, 2020
f80c9c9
Make client name and version non-optional to centralize naming handli…
designatednerd Sep 3, 2020
4abe114
Use a UUID for the task rather than an unsafe mutable raw pointer to …
designatednerd Sep 3, 2020
e9879f2
boop fetch expectation time back down
designatednerd Sep 3, 2020
c295cd9
add now-required parameters to web socket
designatednerd Sep 3, 2020
c6a1f99
fix typo 🤦‍♀️
designatednerd Sep 3, 2020
e363582
use context identifier rather than task identifier to disambiguate id…
designatednerd Sep 3, 2020
fdaf7b4
Fix missing documentation
designatednerd Sep 3, 2020
80927a2
rename identifier to context identifier in callback, add docs to apol…
designatednerd Sep 3, 2020
ba76ace
fix missed `contextIdentifer`
designatednerd Sep 3, 2020
9516ab2
align cache miss on `.returnCacheDataAndFetch` with existing code
designatednerd Sep 3, 2020
e588a52
rm whitespace
designatednerd Sep 3, 2020
624df57
add context identifier to equality comparison on HTTPRequest
designatednerd Sep 4, 2020
4bd0d6a
Remove the retry count from the request and make it a property of the…
designatednerd Sep 4, 2020
caead65
documentation for Parseable
designatednerd Sep 4, 2020
2a6df16
make sure errors are public and localized
designatednerd Sep 4, 2020
e220b02
don't use an apollo store in the codable transport (yet?)
designatednerd Sep 8, 2020
b09ffcb
Make sure Foundation is imported where needed
designatednerd Sep 8, 2020
795af72
make sure foundation is imported on SplitNetworkTransport
designatednerd Sep 8, 2020
bc42ea5
move setup for additional headers into the initializer of HTTPRequest
designatednerd Sep 9, 2020
d18aab3
add debug description for http request
designatednerd Sep 9, 2020
f35ae0a
completely rewrite the `Initialization` document to handle setting up…
designatednerd Sep 9, 2020
3f2a6e7
Make provided interceptor providers open so they can be subclassed.
designatednerd Sep 9, 2020
38135ee
update tutorial for request chain network transport
designatednerd Sep 9, 2020
713430d
Merge pull request #1341 from apollographql/explore/interceptors
designatednerd Sep 11, 2020
bb4b83b
bump version and temporarily update `get-version` script for beta
designatednerd Sep 11, 2020
686f8d5
Regenerate documentation
designatednerd Sep 11, 2020
d916ed1
fix broken link in subscriptions
designatednerd Sep 11, 2020
1910226
update changelog for first beta
designatednerd Sep 11, 2020
1bc9fe8
update xcode and SDK versions covered in tutorial
designatednerd Sep 11, 2020
e51201c
Fix typo 🤦‍♀️
designatednerd Sep 12, 2020
69e2517
Merge branch 'main' into betas/networking-stack + fix merge conflicts
designatednerd Sep 15, 2020
f2226ed
update changelog and bump version
designatednerd Sep 15, 2020
8b745c3
remove things I did on a branch from release notes 🤦‍♀️
designatednerd Sep 16, 2020
e832319
Merge branch 'main' into betas/networking-stack
designatednerd Sep 17, 2020
7bb480e
Merge branch 'main' into betas/networking-stack
designatednerd Sep 17, 2020
40d7e51
Make JSONRequest an open class to allow subclassing
designatednerd Sep 14, 2020
c64e8c8
Fix docs from `ApolloInterceptorProvider` -> `InterceptorProvider`
designatednerd Sep 14, 2020
7c71eda
Add test to make sure when `cancel` is called cancellable interceptor…
designatednerd Sep 17, 2020
8c3c3b6
Add and test method to interceptor provider to allow providing an add…
designatednerd Sep 17, 2020
6c441f9
Make the in-memory cache a default Cache parameter for the store, and…
designatednerd Sep 17, 2020
69da90a
update SQLite and Subscription examples in playground to use new netw…
designatednerd Sep 17, 2020
aea6643
Merge pull request #1399 from apollographql/update/moar-networking
designatednerd Sep 18, 2020
6cd3249
Regenerate docs for new relase
designatednerd Sep 18, 2020
df97514
update version to rc.1
designatednerd Sep 18, 2020
8c5c549
update changelog for RC
designatednerd Sep 18, 2020
5ac7c8c
Merge branch 'main' into betas/networking-stack
designatednerd Sep 18, 2020
ebf7216
Merge branch 'main' into betas/networking-stack
designatednerd Sep 21, 2020
631db65
Allow subclassing of `RequestChainNetworkTransport` to improve creati…
designatednerd Sep 21, 2020
08f3548
Move tests for multipart form data directly into their own class
designatednerd Sep 21, 2020
47257f8
Move testing of upload request construction over to UploadTests
designatednerd Sep 21, 2020
878b24b
Remove multipart stuff from `requestCreator` since there's only one p…
designatednerd Sep 21, 2020
b60a879
Rename RequestCreator -> RequestBodyCreator to disambiguate with `HTT…
designatednerd Sep 21, 2020
7f62310
mark UploadRequest as open
designatednerd Sep 21, 2020
7eb78c7
Rename tests for request body
designatednerd Sep 21, 2020
d11e881
Rename file for test request body creator
designatednerd Sep 21, 2020
357bc9b
Merge pull request #1405 from apollographql/update/creating-requests
designatednerd Sep 22, 2020
c61ac4c
regenerate docs for next release
designatednerd Sep 22, 2020
7485f05
Update tutorial intro with proper version numbers
designatednerd Sep 22, 2020
49afff8
Update changelog and bump version
designatednerd Sep 22, 2020
e80aebc
Add an `#if compiler` statement to allow compilation with non 5.3 ver…
designatednerd Sep 24, 2020
a9bb927
Added a failing test to RequestChainTests.
Sep 25, 2020
94aecaf
Adding the operation type to the request headers
Sep 25, 2020
d6087c6
Added implementation of `additionalErrorInterceptor(for:)` in the mai…
Sep 26, 2020
d188379
Removed where clauses.
Sep 26, 2020
dab6243
Merge pull request #1408 from TizianoCoroneo/tiziano/networking-stack…
designatednerd Sep 26, 2020
00336c8
Merge pull request #1409 from heyzooi/heyzooi-patch-1
designatednerd Sep 27, 2020
1fc2498
take off rc postfix for merge to main
designatednerd Sep 29, 2020
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
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