Skip to content

Commit 7a979f2

Browse files
authored
Merge pull request #89 from marmelab/upgrade-dependencies
[RFR] Upgrade dependencies
2 parents ea945e2 + 3007181 commit 7a979f2

34 files changed

+2936
-2778
lines changed

package.json

+33-33
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,42 @@
3030
]
3131
},
3232
"devDependencies": {
33-
"@babel/cli": "~7.6.3",
34-
"@babel/core": "~7.6.3",
35-
"@babel/plugin-external-helpers": "~7.2.0",
36-
"@babel/plugin-transform-runtime": "~7.6.2",
37-
"@babel/preset-env": "~7.6.3",
38-
"@types/jest": "~24.0.18",
39-
"babel-eslint": "10.0.3",
40-
"babel-jest": "~24.9.0",
41-
"babel-loader": "~8.0.6",
42-
"babel-plugin-add-module-exports": "~1.0.2",
43-
"eslint": "~6.5.1",
44-
"eslint-config-prettier": "~6.4.0",
45-
"eslint-plugin-import": "~2.18.2",
46-
"eslint-plugin-jest": "~22.17.0",
47-
"eslint-plugin-prettier": "~3.1.1",
48-
"husky": "~3.0.8",
49-
"jest": "~24.9.0",
50-
"lint-staged": "~9.4.2",
51-
"prettier": "~1.18.2",
52-
"supertest": "~4.0.2",
53-
"webpack": "~4.41.0",
54-
"webpack-cli": "~3.3.9"
33+
"@babel/cli": "^7.6.3",
34+
"@babel/core": "^7.6.3",
35+
"@babel/plugin-external-helpers": "^7.2.0",
36+
"@babel/plugin-transform-runtime": "^7.6.2",
37+
"@babel/preset-env": "^7.6.3",
38+
"@types/jest": "^25.2.1",
39+
"babel-eslint": "^10.0.3",
40+
"babel-jest": "^25.4.0",
41+
"babel-loader": "^8.0.6",
42+
"babel-plugin-add-module-exports": "^1.0.2",
43+
"eslint": "^6.5.1",
44+
"eslint-config-prettier": "^6.4.0",
45+
"eslint-plugin-import": "^2.18.2",
46+
"eslint-plugin-jest": "^23.8.2",
47+
"eslint-plugin-prettier": "^3.1.1",
48+
"husky": "^4.2.5",
49+
"jest": "^25.4.0",
50+
"lint-staged": "^10.1.7",
51+
"prettier": "^2.0.5",
52+
"supertest": "^4.0.2",
53+
"webpack": "^4.41.0",
54+
"webpack-cli": "^3.3.9"
5555
},
5656
"dependencies": {
57-
"apollo-client": "~2.6.4",
58-
"apollo-test-utils": "~0.3.2",
57+
"apollo-client": "^2.6.4",
58+
"apollo-test-utils": "^0.3.2",
5959
"cors": "^2.8.4",
60-
"express": "~4.17.1",
61-
"express-graphql": "~0.9.0",
62-
"graphql": "~14.5.8",
63-
"graphql-tag": "~2.10.1",
64-
"graphql-tools": "~4.0.5",
65-
"graphql-type-json": "~0.3.0",
66-
"inflection": "~1.12.0",
67-
"lodash.merge": "~4.6.2",
68-
"reify": "~0.20.12",
60+
"express": "^4.17.1",
61+
"express-graphql": "^0.9.0",
62+
"graphql": "^14.5.8",
63+
"graphql-tag": "^2.10.1",
64+
"graphql-tools": "^4.0.5",
65+
"graphql-type-json": "^0.3.0",
66+
"inflection": "^1.12.0",
67+
"lodash.merge": "^4.6.2",
68+
"reify": "^0.20.12",
6969
"xhr-mock": "^2.5.0"
7070
},
7171
"bin": {

src/createApolloClient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ApolloClient } from 'apollo-client';
22
import { mockNetworkInterfaceWithSchema } from 'apollo-test-utils';
33
import getSchemaFromData from './introspection/getSchemaFromData';
44

5-
export default data => {
5+
export default (data) => {
66
const schema = getSchemaFromData(data);
77
const mockNetworkInterface = mockNetworkInterfaceWithSchema({ schema });
88

src/graphQLClientServer.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import mock, { proxy } from 'xhr-mock';
22
import handleRequestFactory from './handleRequest';
33

44
/**
5-
* Starts a GraphQL Server in your browser: intercepts every call to http://localhost:3000/graphql
5+
* Starts a GraphQL Server in your browser: intercepts every call to http://localhost:3000/graphql
66
* and returns a response from the supplied data.
7-
*
7+
*
88
* @export A sinon.js FakeServer (http://sinonjs.org/releases/v2.3.6/fake-xhr-and-server/#fake-server)
9-
* @param {any} data
9+
* @param {any} data
1010
* @param {any} url Specifies the endpoint to intercept (Default is 'http://localhost:3000/graphql').
11-
*
11+
*
1212
* @example
1313
* const data = {
1414
* "posts": [
@@ -36,11 +36,11 @@ import handleRequestFactory from './handleRequest';
3636
* }
3737
* ],
3838
* };
39-
*
39+
*
4040
* GraphQLClientServer(data);
4141
* GraphQLClientServer(data, 'http://localhost:8080/api/graphql');
4242
*/
43-
export default function({ data, url }) {
43+
export default function ({ data, url }) {
4444
const handleRequest = handleRequestFactory(data);
4545

4646
return {
@@ -52,10 +52,10 @@ export default function({ data, url }) {
5252
mock.post(
5353
url,
5454
(req, res) =>
55-
new Promise(resolve => {
55+
new Promise((resolve) => {
5656
handleRequest(url, {
5757
body: req.body(),
58-
}).then(response => {
58+
}).then((response) => {
5959
res.status(response.status);
6060
res.headers(response.headers);
6161
res.body(response.body);

src/handleRequest.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { graphql } from 'graphql';
22
import schemaBuilder from './schemaBuilder';
33

44
/**
5-
* Starts a GraphQL Server in your browser: intercepts every call to http://localhost:3000/graphql
5+
* Starts a GraphQL Server in your browser: intercepts every call to http://localhost:3000/graphql
66
* and returns a response from the supplied data.
7-
*
7+
*
88
* @export A sinon.js FakeServer (http://sinonjs.org/releases/v2.3.6/fake-xhr-and-server/#fake-server)
9-
* @param {any} data
9+
* @param {any} data
1010
* @param {any} url Specifies the endpoint to intercept (Default is 'http://localhost:3000/graphql').
11-
*
11+
*
1212
* @example
1313
* const data = {
1414
* "posts": [
@@ -36,11 +36,11 @@ import schemaBuilder from './schemaBuilder';
3636
* }
3737
* ],
3838
* };
39-
*
39+
*
4040
* GraphQLClientServer(data);
4141
* GraphQLClientServer(data, 'http://localhost:8080/api/graphql');
4242
*/
43-
export default function(data) {
43+
export default function (data) {
4444
const schema = schemaBuilder(data);
4545
return (url, opts = {}) => {
4646
let body = opts.body;
@@ -58,12 +58,12 @@ export default function(data) {
5858
undefined,
5959
query.variables
6060
).then(
61-
result => ({
61+
(result) => ({
6262
status: 200,
6363
headers: { 'Content-Type': 'application/json' },
6464
body: JSON.stringify(result),
6565
}),
66-
error => ({
66+
(error) => ({
6767
status: 500,
6868
headers: { 'Content-Type': 'application/json' },
6969
body: JSON.stringify(error),

src/introspection/getFieldsFromEntities.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import getValuesFromEntities from './getValuesFromEntities';
33

44
/**
55
* Get a list of GraphQL fields from a list of entities
6-
*
6+
*
77
* @example
88
* const entities = [
99
* {

src/introspection/getFilterTypesFromData.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import getValuesFromEntities from './getValuesFromEntities';
1111
import getTypeFromValues from './getTypeFromValues';
1212
import { getTypeFromKey } from '../nameConverter';
1313

14-
const getRangeFiltersFromEntities = entities => {
14+
const getRangeFiltersFromEntities = (entities) => {
1515
const fieldValues = getValuesFromEntities(entities);
1616
return Object.keys(fieldValues).reduce((fields, fieldName) => {
1717
const fieldType = getTypeFromValues(
@@ -35,7 +35,7 @@ const getRangeFiltersFromEntities = entities => {
3535

3636
/**
3737
* Get a list of GraphQLObjectType for filtering data
38-
*
38+
*
3939
* @example
4040
* const data = {
4141
* "posts": [
@@ -89,7 +89,7 @@ const getRangeFiltersFromEntities = entities => {
8989
* // }),
9090
* // }
9191
*/
92-
export default data =>
92+
export default (data) =>
9393
Object.keys(data).reduce(
9494
(types, key) =>
9595
Object.assign({}, types, {

src/introspection/getFilterTypesFromData.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const UsersType = new GraphQLObjectType({
5050

5151
test('creates one filter type per entity', () => {
5252
const filterTypes = getFilterTypesFromData(data);
53-
expect(Object.values(filterTypes).map(type => type.toString())).toEqual([
53+
expect(Object.values(filterTypes).map((type) => type.toString())).toEqual([
5454
'PostFilter',
5555
'UserFilter',
5656
]);

src/introspection/getSchemaFromData.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { getRelatedType } from '../nameConverter';
1919

2020
/**
2121
* Get a GraphQL schema from data
22-
*
22+
*
2323
* @example
2424
* const data = {
2525
* "posts": [
@@ -76,7 +76,7 @@ import { getRelatedType } from '../nameConverter';
7676
* // removeUser(id: ID!): Boolean
7777
* // }
7878
*/
79-
export default data => {
79+
export default (data) => {
8080
const types = getTypesFromData(data);
8181
const typesByName = types.reduce((types, type) => {
8282
types[type.name] = type;
@@ -127,18 +127,19 @@ export default data => {
127127
name: 'Mutation',
128128
fields: types.reduce((fields, type) => {
129129
const typeFields = typesByName[type.name].getFields();
130-
const nullableTypeFields = Object.keys(
131-
typeFields
132-
).reduce((f, fieldName) => {
133-
f[fieldName] = Object.assign({}, typeFields[fieldName], {
134-
type:
135-
fieldName !== 'id' &&
136-
typeFields[fieldName].type instanceof GraphQLNonNull
137-
? typeFields[fieldName].type.ofType
138-
: typeFields[fieldName].type,
139-
});
140-
return f;
141-
}, {});
130+
const nullableTypeFields = Object.keys(typeFields).reduce(
131+
(f, fieldName) => {
132+
f[fieldName] = Object.assign({}, typeFields[fieldName], {
133+
type:
134+
fieldName !== 'id' &&
135+
typeFields[fieldName].type instanceof GraphQLNonNull
136+
? typeFields[fieldName].type.ofType
137+
: typeFields[fieldName].type,
138+
});
139+
return f;
140+
},
141+
{}
142+
);
142143
fields[`create${type.name}`] = {
143144
type: typesByName[type.name],
144145
args: typeFields,
@@ -164,7 +165,7 @@ export default data => {
164165

165166
/**
166167
* extend schema to add relationship fields
167-
*
168+
*
168169
* @example
169170
* If the `post` key contains a 'user_id' field, then
170171
* add one-to-many and many-to-one type extensions:
@@ -174,7 +175,7 @@ export default data => {
174175
const schemaExtension = Object.values(typesByName).reduce((ext, type) => {
175176
Object.keys(type.getFields())
176177
.filter(isRelationshipField)
177-
.map(fieldName => {
178+
.map((fieldName) => {
178179
const relType = getRelatedType(fieldName);
179180
const rel = pluralize(type.toString());
180181
ext += `

src/introspection/getSchemaFromData.spec.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ test('creates three mutation fields per data type', () => {
280280

281281
test('pluralizes and capitalizes correctly', () => {
282282
const data = {
283-
feet: [{ id: 1, size: 42 }, { id: 2, size: 39 }],
283+
feet: [
284+
{ id: 1, size: 42 },
285+
{ id: 2, size: 39 },
286+
],
284287
categories: [{ id: 1, name: 'foo' }],
285288
};
286289
const queries = getSchemaFromData(data).getQueryType().getFields();

src/introspection/getTypeFromValues.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ import {
1010
import GraphQLJSON from 'graphql-type-json';
1111
import DateType from './DateType';
1212

13-
const isNumeric = value => !isNaN(parseFloat(value)) && isFinite(value);
14-
const valuesAreNumeric = values => values.every(isNumeric);
15-
const isInteger = value => Number.isInteger(value);
16-
const valuesAreInteger = values => values.every(isInteger);
17-
const isBoolean = value => typeof value === 'boolean';
18-
const valuesAreBoolean = values => values.every(isBoolean);
19-
const isString = value => typeof value === 'string';
20-
const valuesAreString = values => values.every(isString);
21-
const isArray = value => Array.isArray(value);
22-
const valuesAreArray = values => values.every(isArray);
23-
const isDate = value => value instanceof Date;
24-
const valuesAreDate = values => values.every(isDate);
25-
const isObject = value =>
13+
const isNumeric = (value) => !isNaN(parseFloat(value)) && isFinite(value);
14+
const valuesAreNumeric = (values) => values.every(isNumeric);
15+
const isInteger = (value) => Number.isInteger(value);
16+
const valuesAreInteger = (values) => values.every(isInteger);
17+
const isBoolean = (value) => typeof value === 'boolean';
18+
const valuesAreBoolean = (values) => values.every(isBoolean);
19+
const isString = (value) => typeof value === 'string';
20+
const valuesAreString = (values) => values.every(isString);
21+
const isArray = (value) => Array.isArray(value);
22+
const valuesAreArray = (values) => values.every(isArray);
23+
const isDate = (value) => value instanceof Date;
24+
const valuesAreDate = (values) => values.every(isDate);
25+
const isObject = (value) =>
2626
Object.prototype.toString.call(value) === '[object Object]';
27-
const valuesAreObject = values => values.every(isObject);
27+
const valuesAreObject = (values) => values.every(isObject);
2828

2929
const requiredTypeOrNormal = (type, isRequired) =>
3030
isRequired ? new GraphQLNonNull(type) : type;
@@ -36,7 +36,7 @@ export default (name, values = [], isRequired = false) => {
3636
if (values.length > 0) {
3737
if (valuesAreArray(values)) {
3838
const leafValues = values.reduce((agg, arr) => {
39-
arr.forEach(value => agg.push(value));
39+
arr.forEach((value) => agg.push(value));
4040
return agg;
4141
}, []);
4242
if (valuesAreBoolean(leafValues)) {

src/introspection/getTypeFromValues.spec.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,24 @@ test('returns GraphQLList for arrays', () => {
2020
expect(getTypeFromValues('foo', [[true, false], [true]])).toEqual(
2121
new GraphQLList(GraphQLBoolean)
2222
);
23-
expect(getTypeFromValues('foo', [['a', 'b'], ['c', 'd']])).toEqual(
24-
new GraphQLList(GraphQLString)
25-
);
26-
expect(getTypeFromValues('foo', [[123, 456], [789, 123]])).toEqual(
27-
new GraphQLList(GraphQLInt)
28-
);
29-
expect(getTypeFromValues('foo', [[1.23, 456], [-5, 123]])).toEqual(
30-
new GraphQLList(GraphQLFloat)
31-
);
23+
expect(
24+
getTypeFromValues('foo', [
25+
['a', 'b'],
26+
['c', 'd'],
27+
])
28+
).toEqual(new GraphQLList(GraphQLString));
29+
expect(
30+
getTypeFromValues('foo', [
31+
[123, 456],
32+
[789, 123],
33+
])
34+
).toEqual(new GraphQLList(GraphQLInt));
35+
expect(
36+
getTypeFromValues('foo', [
37+
[1.23, 456],
38+
[-5, 123],
39+
])
40+
).toEqual(new GraphQLList(GraphQLFloat));
3241
});
3342

3443
test('returns GraphQLBoolean for booleans', () =>

0 commit comments

Comments
 (0)