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
Copy file name to clipboardExpand all lines: docs/exchanges.md
+91-28Lines changed: 91 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,78 +165,77 @@ let client = Client.make(
165
165
~exchanges=[
166
166
Client.Exchanges.dedupExchange,
167
167
Client.Exchanges.cacheExchange,
168
-
Client.Exchanges.multipartFetchExchange
168
+
Client.Exchanges.multipartFetchExchange,
169
169
],
170
170
()
171
171
)
172
172
```
173
173
174
174
Read more on the `multipartFetchExchange`[here](https://github.com/FormidableLabs/urql/tree/main/exchanges/multipart-fetch).
175
175
176
-
### `retryExchange`
176
+
### `persistedFetchExchange`
177
177
178
-
The `retryExchange` is useful for retrying particular operations. By default, adding this exchange with the base options will retry any operations that failed due to network errors. However, we can customize the exchange to catch more specific error cases as well.
178
+
The `persistedFetchExchange` adds support for [persisted queries](https://www.onegraph.com/docs/persisted_queries.html), building off of the standard `fetchExchange`.
179
179
180
-
To use the `retryExchange`, add the package to your dependencies:
180
+
To use the `persistedFetchExchange`, add the package to your dependencies:
181
181
182
182
```sh
183
-
yarn add @urql/exchange-retry
183
+
yarn add @urql/exchange-persisted-fetch
184
184
```
185
185
186
-
Then, add the exchange to your array of `exchanges`, specifying the options you want to configure:
186
+
Then, add the exchange to your array of `exchanges`, sepcifying the options you want to configure:
// The persistedFetchExchange only handles queries.
204
+
Client.Exchanges.fetchExchange,
201
205
],
202
206
()
203
207
)
204
208
```
205
209
206
-
By default, `urql` will apply the following configuration for you:
210
+
Read more about the `persistedFetchExchange`[here](https://github.com/FormidableLabs/urql/tree/main/exchanges/persisted-fetch).
207
211
208
-
```typescript
209
-
{
210
-
initialDelayMs: 1000,
211
-
maxDelayMs: 15000,
212
-
randomDelay: true,
213
-
maxNumberAttempts: 2,
214
-
retryIf: err=>err&&err.networkError,
215
-
}
212
+
### `refocusExchange`
213
+
214
+
The `refocusExchange` allows `reason-urql` to redispatch active operations when the window regains focus.
215
+
216
+
To use the `refocusExchange`, add the package to your dependencies:
217
+
218
+
```sh
219
+
yarn add @urql/exchange-refocus
216
220
```
217
221
218
-
If you want to use the defaults from `urql`, call `makeRetryExchangeOptions` with just a `unit` parameter.
222
+
Then, add the exchange to your array of `exchanges`. The `refocusExchange` should be added _after_ the `dedupeExchange`, to prevent doing additional work on requests that are later deduplicated, and _before_ the `fetchExchange`:
Read more on the `retryExchange`[here](https://formidable.com/open-source/urql/docs/advanced/retry-operations/).
239
-
240
239
### `requestPolicyExchange`
241
240
242
241
The `requestPolicyExchange` allows `reason-urql` to automatically upgrade an operation's `requestPolicy` on a time-to-live basis. When the specified TTL has elapsed, `reason-urql` will either:
Read more about the `requestPolicyExchange`[here](https://github.com/FormidableLabs/urql/tree/main/exchanges/request-policy).
280
279
280
+
### `retryExchange`
281
+
282
+
The `retryExchange` is useful for retrying particular operations. By default, adding this exchange with the base options will retry any operations that failed due to network errors. However, we can customize the exchange to catch more specific error cases as well.
283
+
284
+
To use the `retryExchange`, add the package to your dependencies:
285
+
286
+
```sh
287
+
yarn add @urql/exchange-retry
288
+
```
289
+
290
+
Then, add the exchange to your array of `exchanges`, specifying the options you want to configure:
Read more on the `retryExchange`[here](https://formidable.com/open-source/urql/docs/advanced/retry-operations/).
343
+
281
344
## Custom Exchanges
282
345
283
346
`reason-urql` also allows you to write your own exchanges to modify outgoing GraphQL requests and incoming responses. To read up on the basics of exchanges, check out the excellent [`urql` documentation](https://formidable.com/open-source/urql/docs/concepts/exchanges/).
0 commit comments