Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1# @urql/exchange-refocus
2
3`@urql/exchange-refocus` is an exchange for the [`urql`](../../README.md) GraphQL client that tracks currently active operations and redispatches them when the
4window regains focus
5
6## Quick Start Guide
7
8First install `@urql/exchange-refocus` alongside `urql`:
9
10```sh
11yarn add @urql/exchange-refocus
12# or
13npm install --save @urql/exchange-refocus
14```
15
16Then add it to your `Client`, preferably before the `cacheExchange` and in front of any asynchronous
17exchanges, like the `fetchExchange`:
18
19```js
20import { createClient, cacheExchange, fetchExchange } from 'urql';
21import { refocusExchange } from '@urql/exchange-refocus';
22
23const client = createClient({
24 url: 'http://localhost:3000/graphql',
25 exchanges: [refocusExchange({
26 // The minimum time in milliseconds to wait before another refocus can trigger. Default value is 0.
27 minimumTime: 2000
28 }), cacheExchange, fetchExchange],
29});
30```