File tree 2 files changed +18
-6
lines changed
GitHub-GraphQL-API-Example-iOS
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public final class SearchRepositoriesQuery: GraphQLQuery {
16
16
node {
17
17
__typename
18
18
... on Repository {
19
+ __typename
19
20
...RepositoryDetails
20
21
}
21
22
}
@@ -220,6 +221,7 @@ public final class SearchRepositoriesQuery: GraphQLQuery {
220
221
221
222
public static var selections : [ GraphQLSelection ] {
222
223
return [
224
+ GraphQLField ( " __typename " , type: . nonNull( . scalar( String . self) ) ) ,
223
225
GraphQLField ( " __typename " , type: . nonNull( . scalar( String . self) ) ) ,
224
226
GraphQLFragmentSpread ( RepositoryDetails . self) ,
225
227
]
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Apollo
3
3
4
4
private let token = " YOUR_TOKEN "
5
5
6
- class TokenAddingInterceptor : ApolloInterceptor {
6
+ final class TokenAddingInterceptor : ApolloInterceptor {
7
7
func interceptAsync< Operation: GraphQLOperation > (
8
8
chain: RequestChain ,
9
9
request: HTTPRequest < Operation > ,
@@ -14,11 +14,21 @@ class TokenAddingInterceptor: ApolloInterceptor {
14
14
}
15
15
}
16
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
17
+ final class NetworkInterceptorProvider : InterceptorProvider {
18
+ private let client : URLSessionClient
19
+ private let store : ApolloStore
20
+
21
+ init ( client: URLSessionClient , store: ApolloStore ) {
22
+ self . client = client
23
+ self . store = store
24
+ }
25
+
26
+ func interceptors< Operation> ( for operation: Operation ) -> [ ApolloInterceptor ] where Operation : GraphQLOperation {
27
+ [
28
+ TokenAddingInterceptor ( ) ,
29
+ NetworkFetchInterceptor ( client: self . client) ,
30
+ JSONResponseParsingInterceptor ( cacheKeyForObject: self . store. cacheKeyForObject) ,
31
+ ]
22
32
}
23
33
}
24
34
You can’t perform that action at this time.
0 commit comments