Skip to content

Commit

Permalink
refactor: rename gqlErrorsMiddleware to errorMiddleware
Browse files Browse the repository at this point in the history
BREAKING CHANGE: rename `gqlErrorsMiddleware` to `errorMiddleware`
  • Loading branch information
nodkz committed Mar 3, 2018
1 parent de1cacb commit 5a5c3f5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Middlewares
- An example of req/res output in console: <img width="968" alt="screen shot 2017-11-19 at 23 05 19" src="https://user-images.githubusercontent.com/1946920/33159466-557517e0-d03d-11e7-9711-ebdfe6e789c8.png">
- **perfMiddleware** - simple time measure for network request.
- `logger` - log function (default: `console.log.bind(console, '[RELAY-NETWORK]')`)
- **gqlErrorsMiddleware** - 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).
- **errorMiddleware** - 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).
- `logger` - log function (default: `console.error.bind(console)`)
- `prefix` - prefix message (default: `[RELAY-NETWORK] GRAPHQL SERVER ERROR:`)

Expand All @@ -109,7 +109,7 @@ import {
urlMiddleware,
batchMiddleware,
loggerMiddleware,
gqlErrorsMiddleware,
errorMiddleware,
perfMiddleware,
retryMiddleware,
authMiddleware,
Expand All @@ -129,7 +129,7 @@ const network = new RelayNetworkLayer([
batchTimeout: 10,
}),
__DEV__ ? loggerMiddleware() : null,
__DEV__ ? gqlErrorsMiddleware() : null,
__DEV__ ? errorMiddleware() : null,
__DEV__ ? perfMiddleware() : null,
retryMiddleware({
fetchTimeout: 15000,
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import urlMiddleware from './middlewares/url';
import authMiddleware from './middlewares/auth';
import perfMiddleware from './middlewares/perf';
import loggerMiddleware from './middlewares/logger';
import gqlErrorsMiddleware from './middlewares/gqlErrors';
import errorMiddleware from './middlewares/error';
import cacheMiddleware from './middlewares/cache';
import graphqlBatchHTTPWrapper from './express-middleware/graphqlBatchHTTPWrapper';
import RelayNetworkLayerRequest from './RelayRequest';
Expand All @@ -25,7 +25,7 @@ export {
authMiddleware,
perfMiddleware,
loggerMiddleware,
gqlErrorsMiddleware,
errorMiddleware,
cacheMiddleware,
graphqlBatchHTTPWrapper,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`middlewares/gqlErrors should display graphql errors 1`] = `
exports[`middlewares/error should display graphql errors 1`] = `
"[RELAY-NETWORK] GRAPHQL SERVER ERROR:
%cError: Wow!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import fetchMock from 'fetch-mock';
import RelayNetworkLayer from '../../RelayNetworkLayer';
import { mockReq } from '../../__mocks__/mockReq';
import gqlErrorsMiddleware from '../gqlErrors';
import errorMiddleware from '../error';

describe('middlewares/gqlErrors', () => {
describe('middlewares/error', () => {
beforeEach(() => {
fetchMock.restore();
});
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('middlewares/gqlErrors', () => {

const logger = jest.fn();
const rnl = new RelayNetworkLayer([
gqlErrorsMiddleware({
errorMiddleware({
logger,
}),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/gqlErrors.js → src/middlewares/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type GqlErrorMiddlewareOpts = {|
disableServerMiddlewareTip?: boolean,
|};

export default function gqlErrorsMiddleware(options?: GqlErrorMiddlewareOpts): Middleware {
export default function errorMiddleware(options?: GqlErrorMiddlewareOpts): Middleware {
const opts = options || {};
const logger = opts.logger || console.error.bind(console);
const prefix = opts.prefix || '[RELAY-NETWORK] GRAPHQL SERVER ERROR:\n\n';
Expand Down

0 comments on commit 5a5c3f5

Please sign in to comment.