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
[`HTTPInterceptor`](https://www.apollographql.com/docs/ios/docc/documentation/apollo/httpinterceptor) requires you to implement the `intercept(request: next:)` function to perform pre-flight work on the `URLRequest` and post-flight work on the `HTTPResponse`, including the raw response `Data` stream.
177
177
178
-
After the `RequestChain` proceeds through the`GraphQLInterceptor`s provided by it's `InterceptorProvider`, it will call `GraphQLRequest/toURLRequest()` on the final `GraphQLRequest`. Each `HTTPInterceptor` provided by the `InterceptorProvider` will then have it's `intercept(request:next:)` function called in sequential order prior to fetching the request.
178
+
After the `RequestChain` proceeds through each`GraphQLInterceptor` provided by it's `InterceptorProvider`, it will call `GraphQLRequest/toURLRequest()` on the final `GraphQLRequest`. Each `HTTPInterceptor` provided by the `InterceptorProvider` will then have it's `intercept(request:next:)` function called in sequential order prior to fetching the request.
179
179
180
180
The `intercept` function works as follows:
181
181
@@ -193,6 +193,12 @@ The `intercept` function works as follows:
193
193
- Return the `HTTPResponse`
194
194
- When finished, your interceptor must return the `HTTPResponse`, which will be passed back up the chain to the previous `HTTPInterceptor`.
195
195
196
+
<Note>
197
+
198
+
Because an `HTTPInterceptor` does not have access to the `GraphQLRequest`, it cannot trigger a `RequestChain.Retry`. We recommend throwing a custom error from a failing `HTTPInterceptor` and implementing a `GraphQLInterceptor` responsible for error handling to catch the error and trigger a retry with the appropriate `GraphQLRequest`.
199
+
200
+
</Note>
201
+
196
202
### CacheInterceptor
197
203
198
204
[`CacheInterceptor`](https://www.apollographql.com/docs/ios/docc/documentation/apollo/cacheinterceptor) implementations handle cache read and write operations with custom logic beyond what's available through [type/field policies](./../caching/cache-key-resolution). A `CacheInterceptor` must provide two functions, `readCacheData(from store: request:)` and `writeCacheData(to store: request: response)`.
@@ -258,7 +264,7 @@ If you are using a response format other than JSON or that differs from the Grap
258
264
259
265
## Request retries
260
266
261
-
Any interceptor can trigger a request retry by throwing a `RequestChain.Retry` error. When a `RequestChain` receives a thrown `Retry` error, it will restart from the beginning of the [request chain flow](#request-chain-flow) using the `request` provided by the error. This allows the request to be modified to correct errors that may be causing the failure prior to beginning again.
267
+
Any `GraphQLInterceptor` can trigger a request retry by throwing a `RequestChain.Retry` error. When a `RequestChain` receives a thrown `Retry` error, it will restart from the beginning of the [request chain flow](#request-chain-flow) using the `request` provided by the error. This allows the request to be modified to correct errors that may be causing the failure prior to beginning again.
0 commit comments