Skip to content

Commit b062ccc

Browse files
committed
Update packages, fix es6 build
1 parent 4afe093 commit b062ccc

File tree

8 files changed

+59
-61
lines changed

8 files changed

+59
-61
lines changed

.babelrc

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
2-
"presets": ["es2015", "stage-0"],
3-
"plugins": [
4-
"syntax-async-functions",
5-
"transform-class-properties",
6-
"transform-flow-strip-types",
7-
"transform-object-rest-spread",
8-
"transform-regenerator",
9-
"transform-runtime",
10-
],
11-
122
"env": {
133
"cjs": {
14-
"presets": ["es2015-loose", "stage-0"],
15-
"plugins": ["add-module-exports"]
4+
"presets": ["es2015"],
5+
"plugins": [
6+
"syntax-async-functions",
7+
"transform-regenerator",
8+
"transform-class-properties",
9+
"transform-object-rest-spread",
10+
"transform-flow-strip-types",
11+
]
1612
},
1713
"es": {
18-
"presets": ["es2015-loose-native-modules", "stage-0"]
14+
"plugins": [
15+
"syntax-async-functions",
16+
"transform-regenerator",
17+
"transform-class-properties",
18+
"transform-object-rest-spread",
19+
"transform-flow-comments",
20+
]
1921
}
2022
}
2123
}

.flowconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ module.name_mapper='^graphql-compose/lib/definition.js$' -> '/Users/nod/www/_npm
1919
module.name_mapper='^graphql-compose\(.*\)$' -> '/Users/nod/www/_npm/graphql-compose/src\1'
2020
module.name_mapper='^graphql$' -> '/Users/nod/www/_npm/graphql-compose/__forks__/graphql-js/src'
2121
module.name_mapper='^graphql/type/definition.js$' -> '/Users/nod/www/_npm/graphql-compose/__forks__/graphql-js/src/type/definition.js'
22+
23+
[version]
24+
0.28.0

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ Example
99
import composeWithRelay from 'graphql-compose-relay';
1010

1111
composeWithRelay(rootQueryTypeComposer); // add `node` field to RootQuery
12-
composeWithRelay(userTypeComposer); // wrap Type with middlewares, that add fields and tune resolver.
12+
composeWithRelay(userTypeComposer); // wrap Type with middlewares, that add relay's fields and tune resolver.
1313
composeWithRelay(someOtherTypeComposer);
1414
```
1515
That's all!
16-
- No annoying `clientMutationId` manipulations (declaration, passthru, stripping from input).
17-
- Add `id` field to type (or wrap it). This field returns globally unique ID among all types in format `base64(TypeName + ':' + recordId)`
18-
All done internally by middleware for you.
16+
No annoying `clientMutationId` manipulations (declaration, passthru, stripping from input).
17+
No manual adding/wrapping `id` field. This field returns globally unique ID among all types in format `base64(TypeName + ':' + recordId)`.
18+
All relay magic done internally by middleware for you.
1919

2020
Requirements
2121
============
22-
TypeComposer should follow following requirements:
22+
Method `composeWithRelay` accept `TypeComposer` as input argument. So `TypeComposer` should meet following requirements:
2323
- has defined `recordIdFn` (function that from object gives you id)
2424
- should have `findById` resolver
25+
If something is missing `composeWithRelay` throws error.
2526

26-
About `TypeComposer` you may read here [graphql-compose](https://github.com/nodkz/graphql-compose)
27+
`TypeComposer` is [graphql-compose](https://github.com/nodkz/graphql-compose) utility, that wraps GraphQL type and provide bunch of useful methods for type manipulation.
2728

2829
Compatible plugins
2930
==================

package.json

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,51 +23,41 @@
2323
},
2424
"homepage": "https://github.com/nodkz/graphql-compose-relay",
2525
"dependencies": {
26-
"babel-runtime": "^6.6.1",
2726
"graphql-compose": ">=0.0.2"
2827
},
2928
"peerDependencies": {
3029
"graphql": "^0.5.0"
3130
},
3231
"devDependencies": {
33-
"babel-cli": "^6.7.7",
34-
"babel-core": "^6.7.7",
35-
"babel-eslint": "^6.0.3",
36-
"babel-loader": "^6.2.4",
37-
"babel-plugin-add-module-exports": "^0.1.2",
38-
"babel-plugin-dev-expression": "^0.2.1",
39-
"babel-plugin-syntax-async-functions": "^6.8.0",
40-
"babel-plugin-transform-class-properties": "^6.10.2",
41-
"babel-plugin-transform-flow-strip-types": "^6.8.0",
42-
"babel-plugin-transform-object-rest-spread": "^6.8.0",
43-
"babel-plugin-transform-regenerator": "^6.9.0",
44-
"babel-plugin-transform-runtime": "^6.7.5",
45-
"babel-polyfill": "^6.7.4",
46-
"babel-preset-es2015": "^6.6.0",
47-
"babel-preset-es2015-loose": "^7.0.0",
48-
"babel-preset-es2015-loose-native-modules": "^1.0.0",
49-
"babel-preset-stage-0": "^6.5.0",
50-
"babel-register": "^6.7.2",
51-
"chai": "^3.5.0",
52-
"chai-as-promised": "^5.3.0",
53-
"chai-spies": "^0.7.1",
54-
"eslint": "^2.8.0",
55-
"eslint-config-airbnb": "^7.0.0",
56-
"eslint-plugin-jsx-a11y": "^0.6.2",
57-
"eslint-plugin-react": "^4.3.0",
58-
"flow": "^0.2.3",
59-
"flow-bin": "^0.27.0",
60-
"mocha": "^2.5.3",
61-
"rimraf": "^2.5.2",
62-
"sane": "^1.3.4"
32+
"babel-cli": "6.10.1",
33+
"babel-eslint": "6.1.0",
34+
"babel-plugin-syntax-async-functions": "6.8.0",
35+
"babel-plugin-transform-class-properties": "6.10.2",
36+
"babel-plugin-transform-flow-comments": "6.8.0",
37+
"babel-plugin-transform-flow-strip-types": "6.8.0",
38+
"babel-plugin-transform-object-rest-spread": "6.8.0",
39+
"babel-plugin-transform-regenerator": "6.9.0",
40+
"babel-preset-es2015": "6.9.0",
41+
"chai": "3.5.0",
42+
"chai-as-promised": "5.3.0",
43+
"chai-spies": "0.7.1",
44+
"eslint": "2.13.1",
45+
"eslint-config-airbnb": "9.0.1",
46+
"eslint-plugin-flow-vars": "0.4.0",
47+
"eslint-plugin-flowtype": "2.2.7",
48+
"eslint-plugin-import": "1.10.2",
49+
"flow-bin": "0.28.0",
50+
"mocha": "2.5.3",
51+
"rimraf": "2.5.2",
52+
"sane": "1.3.4"
6353
},
6454
"scripts": {
6555
"build": "npm run build-cjs && npm run build-es",
6656
"build-cjs": "rimraf lib && BABEL_ENV=cjs babel src --ignore __tests__,__mocks__ -d lib && cp src/definition.js lib/definition.js",
6757
"build-es": "rimraf es && BABEL_ENV=es babel src --ignore __tests__,__mocks__ -d es && cp src/definition.js es/definition.js",
6858
"lint": "eslint src test *.js",
6959
"prepublish": "npm run build",
70-
"test": "mocha --compilers js:babel-core/register --reporter dot --require ./resources/mocha-bootload src/**/__tests__/**/*-test.js",
71-
"watch": "babel-node ./resources/watch.js"
60+
"test": "BABEL_ENV=cjs babel-node ./node_modules/.bin/_mocha --compilers js:babel-core/register --reporter dot --require ./resources/mocha-bootload src/**/__tests__/**/*-test.js",
61+
"watch": "BABEL_ENV=cjs babel-node ./resources/watch.js"
7262
}
7363
}

resources/mocha-bootload.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable */
22

3-
import chai from 'chai';
4-
import chaiAsPromised from 'chai-as-promised';
5-
import chaiSpies from 'chai-spies';
3+
var chai = require('chai');
4+
var chaiAsPromised = require('chai-as-promised');
5+
var chaiSpies = require('chai-spies');
66

77
chai.use(chaiAsPromised);
88
chai.use(chaiSpies);

resources/watch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ function exec(command, options) {
1313
return new Promise((resolve, reject) => {
1414
var child = spawn(command, options, {
1515
cmd: cmd,
16-
env: process.env,
16+
env: {
17+
...process.env,
18+
BABEL_ENV: 'cjs',
19+
},
1720
stdio: 'inherit'
1821
});
1922
child.on('exit', code => {
@@ -125,7 +128,7 @@ function runTests(filepaths) {
125128
['src/**/__tests__/**/*-test.js']
126129
);
127130
// console.log(cmd);
128-
return exec('node', cmd).catch(() => false);
131+
return exec('babel-node', cmd).catch(() => false);
129132
}
130133

131134
function lintFiles(filepaths) {

src/__tests__/mutationMiddleware-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ describe('MutationMiddleware', () => {
3838
it('should passthru `clientMutationId`', async () => {
3939
const result = await fieldConfig.resolve(
4040
{},
41-
{ input: { clientMutationId: '333' } },
41+
{ input: { clientMutationId: '333' } }
4242
);
4343
expect(result).property('clientMutationId').equal('333');
4444
});
4545

4646
it('should return `nodeId` with globalId', async () => {
4747
const result = await fieldConfig.resolve(
4848
{},
49-
{ input: { id: 'newRecord' } },
49+
{ input: { id: 'newRecord' } }
5050
);
5151
expect(result).property('nodeId').equal(toGlobalId('User', 'newRecord'));
5252
});

src/mutationMiddleware.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {
1313
ResolverMWOutputType,
1414
} from './definition';
1515

16-
1716
export default class MutationMiddleware extends ResolverMiddleware {
1817
// middleware has constructor
1918
// constructor(typeComposer, opts = {}) {
@@ -52,7 +51,7 @@ export default class MutationMiddleware extends ResolverMiddleware {
5251
.then(res => {
5352
res.nodeId = toGlobalId(
5453
this.typeComposer.getTypeName(),
55-
res.recordId,
54+
res.recordId
5655
);
5756
if (clientMutationId) {
5857
res.clientMutationId = clientMutationId;

0 commit comments

Comments
 (0)