From e160029364657fe24f49fcf74e8b012383737c4d Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Fri, 5 Aug 2016 14:21:54 -0500 Subject: [PATCH] Fix a few typos and adjust grammar (#14) --- README.md | 16 ++++++++-------- examples/dataLoaderPerBatchRequest.js | 10 +++++----- src/middleware/auth.js | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 06d3d60..cbb806c 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ ReactRelayNetworkLayer The `ReactRelayNetworkLayer` is a [Relay Network Layer](https://facebook.github.io/relay/docs/guides-network-layer.html) with query batching and middleware support. -This NetworkLayer solves following problems: +This NetworkLayer solves the following problems: - If your app is making enough individual queries to be a performance problem on first page load -- If your app should manipulate request/responce on the fly - change auth headers, request url or made some fallbacks if request fails +- If your app needs to manipulate requests/responses on the fly - change auth headers, request url or perform some fallback if request fails -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`). +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`). Available middlewares: - **url** - for manipulating fetch `url` on fly via thunk. Options: @@ -17,7 +17,7 @@ Available middlewares: - **retry** - for request retry if the initial request fails. Options: * `fetchTimeout` - number in milliseconds that defines in how much time will request timeout after it has been sent to the server (default: `15000`). * `retryDelays` - array of millisecond that defines the values on which retries are based on (default: `[1000, 3000]`). - * `statusCodes` - array of response status codes which will fire up retryMiddleware (default: `status < 200 or status > 300`). + * `statusCodes` - array of response status codes which will fire up retryMiddleware (default: `status < 200 or status > 300`). * `allowMutations` - by default retries disabled for mutations, you may allow process retries for them passing `true` (default: `false`) * `forceRetry` - function(cb, delay), when request is delayed for next retry, middleware will call this function and pass to it a callback and delay time. When you call this callback, middleware will proceed request immediately (default: `false`). - **auth** - for adding auth token, and refreshing it if gets 401 response from server. Options: @@ -34,7 +34,7 @@ Available middlewares: * `logger` - log function (default: `console.log.bind(console, '[RELAY-NETWORK]')`) - **gqErrors** - display `errors` data to console from graphql response. If you want see stackTrace for errors, you should provide `formatError` to `express-graphql` (see example below where `graphqlServer` accept `formatError` function). Options: * `logger` - log function (default: `console.error.bind(console)`) - * `prefix` - prefix message (dafault: `[RELAY-NETWORK] GRAPHQL SERVER ERROR:`) + * `prefix` - prefix message (default: `[RELAY-NETWORK] GRAPHQL SERVER ERROR:`) - **defer** - _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). [CHANGELOG](https://github.com/nodkz/react-relay-network-layer/blob/master/CHANGELOG.md) @@ -152,7 +152,7 @@ Relay.injectNetworkLayer(new RelayNetworkLayer([ next => req => { req.headers['X-Request-ID'] = uuid.v4(); // add `X-Request-ID` to request headers req.credentials = 'same-origin'; // provide CORS policy to XHR request in fetch method - + // internally works following code: // let { url, ...opts } = req; // fetch(url, opts) @@ -205,12 +205,12 @@ Middlewares use LIFO (last in, first out) stack. Or simply put - use `compose` f TODO ==== -- [ ] Add support for graphql subscriptions. But firstly need [graphql-compose](https://github.com/nodkz/graphql-compose) for schema building, which is in heavy development right now (**planned for version 2.0.0**) +- [ ] Add support for graphql subscriptions. But firstly need [graphql-compose](https://github.com/nodkz/graphql-compose) for schema building, which is in heavy development right now (**planned for version 2.0.0**) - [ ] Add tests and cover by flowtype - [ ] Rewrite `batching` as middleware, keep in mind principles of how works [DataLoader](https://github.com/facebook/dataloader) via eventLoop (`process.nextTick()`) (**planned for version 2.0.0**) - [ ] Support `defer`, see [relay/issues/288](https://github.com/facebook/relay/issues/288) - [ ] Find brave peoples - - who made fixes and remove misspelling and missunderstanding in readme.MD + - who made fixes and remove misspelling and misunderstanding in readme.MD Contribute diff --git a/examples/dataLoaderPerBatchRequest.js b/examples/dataLoaderPerBatchRequest.js index 07e8d7f..6da6613 100644 --- a/examples/dataLoaderPerBatchRequest.js +++ b/examples/dataLoaderPerBatchRequest.js @@ -2,7 +2,7 @@ Example of how you can use a single DataLoader for all (batched) queries within a single HTTP-request. -Tunned for performance, to avoid creating unnececary functions per each request. +Tuned for performance, to avoid creating unnecessary functions per request. */ import express from 'express'; @@ -29,7 +29,7 @@ const initDataLoaders = () => { }; }; -// for performance reason, create once error function converter (rather than for every request) +// for performance reasons, create a single error function converter (rather than every request) const formatError = (error) => ({ // better errors for development. `stack` used in `gqErrors` middleware message: error.message, @@ -51,9 +51,9 @@ const graphqlSettingsPerRequest = (req) => ({ // Declare route for batch query // `graphqlBatchHTTPWrapper` and `graphqlHTTP` return arrow functions. -// So for performance reason declare it once outside (req, res, next) => {} block. -// Rather than declare it every time for each request, -// as it will result in the garbage collector being invoked way more than is necessary. +// For performance reasons, declare it once outside (req, res, next) => {} block, +// rather than for every request. Otherwise, it will result in the garbage collector +// being invoked way more than necessary. const graphqlBatchMiddleware = graphqlBatchHTTPWrapper( graphqlHTTP(req => req.graphqlServerSettings) ); diff --git a/src/middleware/auth.js b/src/middleware/auth.js index 9052f2f..36ba345 100644 --- a/src/middleware/auth.js +++ b/src/middleware/auth.js @@ -32,7 +32,7 @@ export default function authMiddleware(opts = {}) { return next(req); }).then(res => { if (res.status === 401 && tokenRefreshPromise) { - throw new WrongTokenError('Was recieved status 401 from server', res); + throw new WrongTokenError('Received status 401 from server', res); } return res; }).catch(err => {