Skip to content

Commit 0f1817d

Browse files
authored
Merge pull request #6 from shingt/xcode-12.5
Xcode 12.5
2 parents 7eee16b + 4865b68 commit 0f1817d

File tree

6 files changed

+61
-40
lines changed

6 files changed

+61
-40
lines changed

GitHub-GraphQL-API-Example-iOS.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@
402402
repositoryURL = "https://github.com/apollographql/apollo-ios.git";
403403
requirement = {
404404
kind = upToNextMinorVersion;
405-
minimumVersion = 0.34.1;
405+
minimumVersion = 0.43.0;
406406
};
407407
};
408408
/* End XCRemoteSwiftPackageReference section */

GitHub-GraphQL-API-Example-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GitHub-GraphQL-API-Example-iOS/API.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public final class SearchRepositoriesQuery: GraphQLQuery {
2626

2727
public let operationName: String = "SearchRepositories"
2828

29-
public var queryDocument: String { return operationDefinition.appending("\n" + RepositoryDetails.fragmentDefinition) }
29+
public var queryDocument: String {
30+
var document: String = operationDefinition
31+
document.append("\n" + RepositoryDetails.fragmentDefinition)
32+
return document
33+
}
3034

3135
public var query: String
3236
public var count: Int

GitHub-GraphQL-API-Example-iOS/Base.lproj/LaunchScreen.storyboard

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
56
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
67
</dependencies>
78
<scenes>
@@ -14,7 +15,7 @@
1415
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
1516
</layoutGuides>
1617
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
17-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
18+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1819
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1920
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2021
</view>

GitHub-GraphQL-API-Example-iOS/Main.storyboard

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="iya-P1-MDn">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="iya-P1-MDn">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
7-
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
9-
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
106
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
117
</dependencies>
128
<scenes>
139
<!--Navigation Controller-->
1410
<scene sceneID="vaP-L4-xAt">
1511
<objects>
16-
<placeholder placeholderIdentifier="IBFirstResponder" id="MlA-EN-ZHx" userLabel="First Responder" sceneMemberID="firstResponder"/>
1712
<navigationController id="iya-P1-MDn" sceneMemberID="viewController">
1813
<navigationBar key="navigationBar" contentMode="scaleToFill" id="nJ3-es-t9P">
19-
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
2014
<autoresizingMask key="autoresizingMask"/>
2115
</navigationBar>
2216
<connections>
2317
<segue destination="Mz3-K0-ASN" kind="relationship" relationship="rootViewController" id="pcq-al-irZ"/>
2418
</connections>
2519
</navigationController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="MlA-EN-ZHx" userLabel="First Responder" sceneMemberID="firstResponder"/>
2621
</objects>
2722
<point key="canvasLocation" x="-655" y="182"/>
2823
</scene>

GitHub-GraphQL-API-Example-iOS/RepositoriesViewController.swift

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ import Apollo
33

44
private let token = "YOUR_TOKEN"
55

6+
class TokenAddingInterceptor: ApolloInterceptor {
7+
func interceptAsync<Operation: GraphQLOperation>(
8+
chain: RequestChain,
9+
request: HTTPRequest<Operation>,
10+
response: HTTPResponse<Operation>?,
11+
completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void) {
12+
request.addHeader(name: "Authorization", value: "Bearer \(token)")
13+
chain.proceedAsync(request: request, response: response, completion: completion)
14+
}
15+
}
16+
17+
class NetworkInterceptorProvider: LegacyInterceptorProvider {
18+
override func interceptors<Operation: GraphQLOperation>(for operation: Operation) -> [ApolloInterceptor] {
19+
var interceptors = super.interceptors(for: operation)
20+
interceptors.insert(TokenAddingInterceptor(), at: 0)
21+
return interceptors
22+
}
23+
}
24+
625
final class RepositoriesViewController: UITableViewController {
726
private var repositories: [SearchRepositoriesQuery.Data.Search.Edge.Node.AsRepository]? {
827
didSet {
@@ -11,14 +30,16 @@ final class RepositoriesViewController: UITableViewController {
1130
}
1231

1332
private lazy var apollo: ApolloClient = {
14-
let network = RequestChainNetworkTransport(
15-
interceptorProvider: LegacyInterceptorProvider(),
16-
endpointURL: URL(string: "https://api.github.com/graphql")!,
17-
additionalHeaders: [
18-
"Authorization": "Bearer \(token)"
19-
]
33+
let client = URLSessionClient()
34+
let cache = InMemoryNormalizedCache()
35+
let store = ApolloStore(cache: cache)
36+
let provider = NetworkInterceptorProvider(client: client, store: store)
37+
let url = URL(string: "https://api.github.com/graphql")!
38+
let transport = RequestChainNetworkTransport(
39+
interceptorProvider: provider,
40+
endpointURL: url
2041
)
21-
return .init(networkTransport: network)
42+
return .init(networkTransport: transport, store: store)
2243
}()
2344

2445
override func viewWillAppear(_ animated: Bool) {

0 commit comments

Comments
 (0)