You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 26, 2021. It is now read-only.
If you've used [Apollo iOS](https://github.com/apollographql/apollo-ios) library,
12
+
If you used [Apollo iOS](https://github.com/apollographql/apollo-ios) library,
13
13
you may have stumbled upon a few limitations of a standard `HTTPNetworkTransport`
14
14
provided with the library:
15
15
16
-
*[Can't swap request headers without creating a new `ApolloClient` instance](https://github.com/apollographql/apollo-ios/issues/37)
17
-
*[Can't send requests when the app is in background](https://stackoverflow.com/questions/50089546/how-to-correctly-use-apollo-graphql-on-ios-with-background-session-configuration)
-[Can't swap request headers without creating a new `ApolloClient` instance](https://github.com/apollographql/apollo-ios/issues/37)
17
+
-[Can't send requests when the app is in background](https://stackoverflow.com/questions/50089546/how-to-correctly-use-apollo-graphql-on-ios-with-background-session-configuration)
Fortunately, Apollo iOS provides a public `NetworkTransport` protocol that allows
20
+
Fortunately, Apollo iOS provides a public `NetworkTransport` protocol that allows
21
21
us to override behaviour that's limited. Looks like [Alamofire](https://github.com/Alamofire/Alamofire)
22
-
is the most popular iOS networking library and all of the mentioned limitations can be solved
23
-
with it. You also probably use Alamofire anyway to acquire authentication tokens for your
22
+
is the most popular iOS networking library and all of the mentioned limitations can be solved
23
+
with it. You also probably use Alamofire anyway to acquire authentication tokens for your
24
24
GraphQL API, so it makes sense to integrate both Alamofire and Apollo iOS.
25
25
26
26
This package bundles a `NetworkTransport` implementation that wraps Alamofire
@@ -29,11 +29,14 @@ and solves these limitations.
29
29
## Example
30
30
31
31
When initialising a new `ApolloClient` instance instead of
32
+
32
33
```swift
33
34
let u =URL(string: "http://localhost:8080/graphql")!
34
35
let client =ApolloClient(url: u)
35
36
```
37
+
36
38
or instead of
39
+
37
40
```swift
38
41
let u =URL(string: "http://localhost:8080/graphql")!
39
42
let client =ApolloClient(networkTransport: HTTPNetworkTransport(url: u))
@@ -49,7 +52,7 @@ let u = URL(string: "http://localhost:8080/graphql")!
49
52
let client =ApolloClient(networkTransport: AlamofireTransport(url: u))
50
53
```
51
54
52
-
There are additional parameters available for `AlamofireTransport` initialiser, e.g. for
55
+
There are additional parameters available for `AlamofireTransport` initialiser, e.g. for
53
56
a background session you can use it like this:
54
57
55
58
```swift
@@ -62,7 +65,6 @@ let client = ApolloClient(networkTransport: t)
62
65
63
66
like this for auth headers:
64
67
65
-
66
68
```swift
67
69
let token ="blah"
68
70
let u =URL(string: "http://localhost:8080/graphql")!
@@ -81,11 +83,11 @@ let client = ApolloClient(networkTransport: t)
81
83
82
84
Both `headers` and `loggingEnabled` are also variable properties of `AlamofireTransport`.
83
85
This allows you to change headers without instantiating a new transport, e.g. when a user
84
-
logs out and a different user logs in you can swap authentication headers. If you switch
85
-
logging dynamically, `loggingEnabled` property can be controlled in the same way
86
+
logs out and a different user logs in you can swap authentication headers. If you switch
87
+
logging dynamically, `loggingEnabled` property can be controlled in the same way
86
88
without creating a new `AlamofireTransport` instance.
87
89
88
-
Nice feature of Alamofire is that request logging prints a ready for use
90
+
Nice feature of Alamofire is that request logging prints a ready for use
89
91
[curl command](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#curl-command-output), which you can directly copy and paste in terminal to test a request.
90
92
91
93
All of the initialiser parameters except `url` have sensible default values and can be used
@@ -95,20 +97,24 @@ To run the example project, clone the repo, and open `Example/ApolloAlamofire.xc
95
97
96
98
## Requirements
97
99
98
-
* Xcode 10.0 or later
99
-
* Swift 4.2 or later
100
+
- Xcode 10.0 or later
101
+
- Swift 4.2 or later
102
+
- iOS 9.0 deployment target or later.
103
+
104
+
If you integrate the library with CocoaPods, Alamofire and Apollo iOS
105
+
dependencies are pulled automatically. Currently tested compatible versions are
106
+
Alamofire 4.x and Apollo iOS 0.10.x.
100
107
101
-
If you integrate the library with CocoaPods, Alamofire and Apollo iOS dependencies are
102
-
pulled automatically. Currently tested versions that should be compatible are Alamofire 4.x
103
-
and Apollo iOS 0.10.x.
108
+
If you need Xcode 9 and Swift 4.0 support in your project you can use earlier
109
+
version of ApolloAlamofire: [0.3.0](https://github.com/graphql-community/ApolloAlamofire/tree/0.3.0).
104
110
105
111
## Installation
106
112
107
113
ApolloAlamofire is available through [CocoaPods](https://cocoapods.org). To install
108
114
it, simply add the following line to your target configuration in your Podfile:
0 commit comments