Skip to content

Commit 10b4ec2

Browse files
authored
Merge pull request #22 from relay-tools/chore
Update tooling
2 parents 03c882b + d39d786 commit 10b4ec2

File tree

13 files changed

+162
-150
lines changed

13 files changed

+162
-150
lines changed

.babelrc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"stage": 0,
3-
"loose": "all",
4-
"optional": [
5-
"runtime"
6-
]
2+
"presets": ["es2015-loose", "stage-1"],
3+
"plugins": ["add-module-exports"]
74
}

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": "airbnb",
2+
"extends": "airbnb-base",
33
"parser": "babel-eslint"
44
}

karma.conf.babel.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

karma.conf.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
1-
require('babel-core/register');
2-
module.exports = require('./karma.conf.babel.js');
1+
const webpack = require('webpack');
2+
3+
module.exports = config => {
4+
const { env } = process;
5+
6+
const isCi = env.CONTINUOUS_INTEGRATION === 'true';
7+
8+
config.set({
9+
frameworks: ['mocha', 'sinon-chai'],
10+
11+
files: ['test/index.js'],
12+
13+
preprocessors: {
14+
'test/index.js': ['webpack', 'sourcemap'],
15+
},
16+
17+
webpack: {
18+
module: {
19+
loaders: [
20+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
21+
],
22+
},
23+
plugins: [
24+
new webpack.DefinePlugin({
25+
'process.env.NODE_ENV': JSON.stringify('test'),
26+
}),
27+
],
28+
devtool: 'cheap-module-inline-source-map',
29+
},
30+
31+
webpackMiddleware: {
32+
noInfo: true,
33+
},
34+
35+
reporters: ['mocha'],
36+
37+
mochaReporter: {
38+
output: 'autowatch',
39+
},
40+
41+
customLaunchers: {
42+
ChromeCi: {
43+
base: 'Chrome',
44+
flags: ['--no-sandbox'],
45+
},
46+
},
47+
48+
browsers: env.BROWSER ? env.BROWSER.split(',') : ['Chrome'],
49+
50+
singleRun: isCi,
51+
});
52+
};

package.json

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"build-fixtures": "babel-node test/fixtures/updateSchema.js",
1212
"lint": "eslint src test *.js",
1313
"prepublish": "npm run build",
14-
"test": "npm run lint && npm run build-fixtures && karma start"
14+
"test": "npm run build-fixtures && npm run lint && npm run testonly",
15+
"testonly": "karma start"
1516
},
1617
"repository": {
1718
"type": "git",
@@ -28,41 +29,48 @@
2829
"url": "https://github.com/relay-tools/relay-local-schema/issues"
2930
},
3031
"homepage": "https://github.com/relay-tools/relay-local-schema#readme",
31-
"dependencies": {
32-
"babel-runtime": "^5.8.38"
33-
},
3432
"peerDependencies": {
3533
"graphql": "^0.5.0 || ^0.6.0",
3634
"react-relay": ">=0.8.0"
3735
},
3836
"devDependencies": {
39-
"babel": "^5.8.38",
40-
"babel-core": "^5.8.38",
41-
"babel-eslint": "^4.1.8",
42-
"babel-loader": "^5.4.0",
43-
"babel-relay-plugin": "^0.8.0",
37+
"babel-cli": "^6.10.1",
38+
"babel-core": "^6.10.4",
39+
"babel-eslint": "^6.1.2",
40+
"babel-loader": "^6.2.4",
41+
"babel-plugin-add-module-exports": "^0.2.1",
42+
"babel-polyfill": "^6.9.1",
43+
"babel-preset-es2015": "^6.9.0",
44+
"babel-preset-es2015-loose": "^7.0.0",
45+
"babel-preset-react": "^6.11.1",
46+
"babel-preset-stage-0": "^6.5.0",
47+
"babel-preset-stage-1": "^6.5.0",
48+
"babel-relay-plugin": "^0.9.2",
4449
"chai": "^3.5.0",
45-
"eslint": "^1.10.3",
46-
"eslint-config-airbnb": "^5.0.1",
47-
"eslint-plugin-react": "^3.16.1",
48-
"graphql": "^0.6.0",
50+
"eslint": "^2.13.1",
51+
"eslint-config-airbnb": "^9.0.1",
52+
"eslint-config-airbnb-base": "^3.0.1",
53+
"eslint-plugin-import": "^1.10.2",
54+
"eslint-plugin-jsx-a11y": "^1.5.5",
55+
"eslint-plugin-react": "^5.2.2",
56+
"graphql": "^0.6.1",
4957
"graphql-relay": "^0.4.2",
50-
"karma": "^0.13.22",
51-
"karma-chrome-launcher": "^0.2.3",
52-
"karma-firefox-launcher": "^0.1.7",
53-
"karma-mocha": "^0.2.2",
54-
"karma-mocha-reporter": "^2.0.0",
55-
"karma-sinon-chai": "^1.2.0",
58+
"karma": "^1.1.1",
59+
"karma-chrome-launcher": "^1.0.1",
60+
"karma-firefox-launcher": "^1.0.0",
61+
"karma-mocha": "^1.1.1",
62+
"karma-mocha-reporter": "^2.0.4",
63+
"karma-sinon-chai": "^1.2.3",
5664
"karma-sourcemap-loader": "^0.3.7",
5765
"karma-webpack": "^1.7.0",
58-
"lolex": "^1.4.0",
59-
"mocha": "^2.4.5",
60-
"react": "^15.0.1",
61-
"react-dom": "^15.0.1",
62-
"react-relay": "^0.8.0",
63-
"rimraf": "^2.5.2",
64-
"sinon": "^1.17.3",
66+
"mocha": "^2.5.3",
67+
"react": "^15.2.1",
68+
"react-addons-test-utils": "^15.2.1",
69+
"react-dom": "^15.2.1",
70+
"react-relay": "^0.9.2",
71+
"rimraf": "^2.5.3",
72+
"sinon": "^1.17.4",
6573
"sinon-chai": "^2.8.0",
66-
"webpack": "^1.12.15"
74+
"webpack": "^1.13.1"
6775
}
6876
}

src/NetworkLayer.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ import formatRequestErrors from './__forks__/formatRequestErrors';
44

55
export default class NetworkLayer {
66
constructor({ schema, rootValue, contextValue, onError }) {
7-
this._schema = schema;
8-
this._rootValue = rootValue;
9-
this._contextValue = contextValue;
10-
this._onError = onError;
7+
this.schema = schema;
8+
this.rootValue = rootValue;
9+
this.context = contextValue;
10+
this.onError = onError;
1111
}
1212

1313
sendMutation(mutationRequest) {
1414
if (mutationRequest.getFiles()) {
1515
throw new Error('uploading files not supported');
1616
}
1717

18-
return this._executeRequest('mutation', mutationRequest);
18+
return this.executeRequest('mutation', mutationRequest);
1919
}
2020

2121
sendQueries(queryRequests) {
2222
return Promise.all(queryRequests.map(queryRequest =>
23-
this._executeRequest('query', queryRequest)
23+
this.executeRequest('query', queryRequest)
2424
));
2525
}
2626

27-
async _executeRequest(requestType, request) {
27+
async executeRequest(requestType, request) {
2828
const { data, errors } = await graphql(
29-
this._schema,
29+
this.schema,
3030
request.getQueryString(),
31-
this._rootValue,
32-
this._contextValue,
31+
this.rootValue,
32+
this.context,
3333
request.getVariables()
3434
);
3535

@@ -38,9 +38,10 @@ export default class NetworkLayer {
3838
`Failed to execute ${requestType} \`${request.getDebugName()}\` for ` +
3939
`the following reasons:\n\n${formatRequestErrors(request, errors)}`
4040
));
41-
if (this._onError) {
42-
this._onError(errors, request);
41+
if (this.onError) {
42+
this.onError(errors, request);
4343
}
44+
4445
return;
4546
}
4647

test/.babelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"passPerPreset": true,
3+
"presets": [
4+
{ "plugins": ["./fixtures/babelRelayPlugin"] },
5+
"react",
6+
"es2015-loose",
7+
8+
// FIXME: Workaround for https://phabricator.babeljs.io/T7274. This should
9+
// be stage-1.
10+
"stage-0"
11+
]
12+
}

test/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": "airbnb",
23
"env": {
34
"mocha": true
45
},

0 commit comments

Comments
 (0)