Skip to content

Commit 6387d32

Browse files
committed
docs(Readme): Update docs with changes in 2.0.0
1 parent a5b6f1b commit 6387d32

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ReactRelayNetworkLayer
2-
======================
1+
ReactRelayNetworkLayer 2
2+
========================
33
[![](https://img.shields.io/npm/v/react-relay-network-layer.svg)](https://www.npmjs.com/package/react-relay-network-layer)
44
[![npm](https://img.shields.io/npm/dt/react-relay-network-layer.svg)](http://www.npmtrends.com/react-relay-network-layer)
55
[![Travis](https://img.shields.io/travis/nodkz/react-relay-network-layer.svg?maxAge=2592000)](https://travis-ci.org/nodkz/react-relay-network-layer)
@@ -11,8 +11,19 @@ with various middlewares which can manipulate requests/responses on the fly (cha
1111

1212
`ReactRelayNetworkLayer` can be used in browser, react-native or node server for rendering. Under the hood this module uses global `fetch` method. So if your client is too old, please import explicitly proper polyfill to your code (eg. `whatwg-fetch`, `node-fetch` or `fetch-everywhere`).
1313

14+
```
15+
yarn add react-relay-network-layer
16+
OR
17+
npm install react-relay-network-layer --save
18+
```
19+
1420
### Migrating from v1 to v2
15-
In v2 was completely rewritten batch logic as middleware. All other parts stay unaffected. So if you use request batching, you should change your config:
21+
Changes in v2.0.0:
22+
- completely rewritten batch logic as middleware, added additional cool options to it `batchTimeout`, `maxBatchSize`
23+
- throw Error object on non-200 response (before thrown response)
24+
- much more tests
25+
26+
All other parts stay unaffected. So if you use `request batching`, you should change your config:
1627
```diff
1728
import Relay from 'react-relay';
1829
import {
@@ -32,18 +43,24 @@ Relay.injectNetworkLayer(new RelayNetworkLayer([
3243
- ], { disableBatchQuery: false }));
3344
+ ]));
3445
```
46+
47+
Big thanks to @brad-decker and @jeanregisser in helping to done this release.
48+
3549
Previous documentation for version 1.x.x can be found [here](https://github.com/nodkz/react-relay-network-layer/blob/6eb361668cd81b760a8c99e8265f10416d802dd3/README.md).
3650

51+
Middlewares
52+
===========
53+
3754
### Available middlewares:
3855
- **your custom inline middleware** - [see example](https://github.com/nodkz/react-relay-network-layer#example-of-injecting-networklayer-with-middlewares-on-the-client-side) below where added `credentials` and `headers` to the `fetch` method.
3956
- `next => req => { /* your modification of 'req' object */ return next(req); }`
4057
- **urlMiddleware** - for manipulating fetch `url` on fly via thunk.
4158
- `url` - string or function(req) for single request (default: `/graphql`)
42-
- **batchMiddleware** - gather some period of time relay-requests and sends it as one http-request
59+
- **batchMiddleware** - gather some period of time relay-requests and sends it as one http-request. You server must support batch request, [how to setup your server](https://github.com/nodkz/react-relay-network-layer#example-how-to-enable-batching)
4360
- `batchUrl` - string or function(requestMap). Url of the server endpoint for batch request execution (default: `/graphql/batch`)
44-
- `batchTimeout` - integer in milliseconds, period of time for gathering multiple requests before sending them to the server (default: `0`)
61+
- `batchTimeout` - integer in milliseconds, period of time for gathering multiple requests before sending them to the server. Will delay sending of the requests on specified in this option period of time, so be careful and keep this value small. (default: `0`)
62+
- `maxBatchSize` - integer representing maximum size of request to be sent in a single batch. Once a request hits the provided size in length a new batch request is ran. Actual for hardcoded limit in 100kb per request in [express-graphql](https://github.com/graphql/express-graphql/blob/master/src/parseBody.js#L112) module. (default: `102400` characters, roughly 100kb for 1-byte characters or 200kb for 2-byte characters)
4563
- `allowMutations` - by default batching disabled for mutations, you may enable it passing `true` (default: `false`)
46-
- `maxBatchSize` - integer representing maximum size of request to be sent in a single batch. Once a request hits the provided size in length a new batch request is ran. (default: `102400` characters, roughly 100kb for 1-byte characters or 200kb for 2-byte characters)
4764
- **retryMiddleware** - for request retry if the initial request fails.
4865
- `fetchTimeout` - number in milliseconds that defines in how much time will request timeout after it has been sent to the server (default: `15000`).
4966
- `retryDelays` - array of millisecond that defines the values on which retries are based on (default: `[1000, 3000]`).
@@ -68,19 +85,6 @@ Previous documentation for version 1.x.x can be found [here](https://github.com/
6885
- `prefix` - prefix message (default: `[RELAY-NETWORK] GRAPHQL SERVER ERROR:`)
6986
- **deferMiddleware** - _experimental_ Right now `deferMiddleware()` just set `defer` as supported option for Relay. So this middleware allow to community play with `defer()` in cases, which was [described by @wincent](https://github.com/facebook/relay/issues/288#issuecomment-199510058).
7087

71-
[CHANGELOG](https://github.com/nodkz/react-relay-network-layer/blob/master/CHANGELOG.md)
72-
73-
Installation
74-
============
75-
76-
```
77-
yarn add react-relay-network-layer
78-
OR
79-
npm install react-relay-network-layer --save
80-
```
81-
82-
Middlewares
83-
===========
8488
### Example of injecting NetworkLayer with middlewares on the **client side**.
8589
```js
8690
import Relay from 'react-relay';
@@ -261,6 +265,8 @@ Contribute
261265
I actively welcome pull requests with code and doc fixes.
262266
Also if you made great middleware and want share it within this module, please feel free to open PR.
263267

268+
[CHANGELOG](https://github.com/nodkz/react-relay-network-layer/blob/master/CHANGELOG.md)
269+
264270

265271
License
266272
=======

0 commit comments

Comments
 (0)