Skip to content

Commit 753e63e

Browse files
committed
Update tooling
1 parent 918a426 commit 753e63e

12 files changed

+2869
-5881
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lib
1+
dist
22
node_modules
33
.nvmrc
44
.nyc_output

.travis.yml

-20
This file was deleted.

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ install: package.json ## Install dependencies
1010
@$(PKG) install
1111

1212
watch: ## continuously compile ES6 files to JS
13-
NODE_ENV=development ./node_modules/.bin/webpack --watch
13+
@yarn vite build --watch
1414

1515
test: ## Launch unit tests
16-
@NODE_ENV=test ./node_modules/.bin/jest
16+
@NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest
1717

1818
watch-test: ## Launch unit tests and watch for changes
19-
@NODE_ENV=test ./node_modules/.bin/jest --watch
19+
@NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest --watch
2020

2121
format: ## Format the source code
2222
@./node_modules/.bin/eslint --fix ./src
@@ -25,4 +25,4 @@ run: ## Launch server with example data
2525
@node ./bin/json-graphql-server.js example/data.js
2626

2727
build: ## Build production release
28-
@NODE_ENV=production ./node_modules/.bin/webpack
28+
@yarn vite build

babel.config.js

-38
This file was deleted.

bin/json-graphql-server.js bin/json-graphql-server.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require('reify');
33
var path = require('path');
44
var express = require('express');
55
var cors = require('cors');
6-
var JsonGraphqlServer = require('../lib/json-graphql-server.node.min').default;
6+
var JsonGraphqlServer = require('../dist/json-graphql-server').default;
77

88
var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json';
99
var data = require(path.join(process.cwd(), dataFilePath));
@@ -23,7 +23,7 @@ process.argv.forEach((arg, index) => {
2323
});
2424

2525
app.use(cors());
26-
app.use('/', JsonGraphqlServer(data));
26+
app.use('/', JsonGraphqlServer({ data }).getHandler());
2727
app.listen(PORT, HOST);
2828
var msg = `GraphQL server running with your data at http://${HOST}:${PORT}/`;
2929
console.log(msg); // eslint-disable-line no-console

package.json

+30-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
22
"name": "json-graphql-server",
33
"version": "2.4.1",
4-
"main": "lib/json-graphql-server.node.min.js",
5-
"browser": "lib/json-graphql-server.client.min.js",
4+
"type": "module",
5+
"main": "./dist/json-graphql-server.umd.cjs",
6+
"module": "./dist/json-graphql-server.js",
7+
"exports": {
8+
".": {
9+
"import": "./dist/json-graphql-server.js",
10+
"require": "./dist/json-graphql-server.umd.cjs"
11+
}
12+
},
613
"repository": "[email protected]:marmelab/json-graphql-server.git",
714
"authors": [
815
"François Zaninotto",
@@ -30,42 +37,34 @@
3037
]
3138
},
3239
"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": "^25.2.1",
40+
"@types/jest": "^29.5.12",
3941
"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"
42+
"babel-jest": "^29.7.0",
43+
"eslint": "^9.0.0",
44+
"eslint-config-prettier": "^9.1.0",
45+
"eslint-plugin-import": "^2.29.1",
46+
"eslint-plugin-jest": "^28.2.0",
47+
"eslint-plugin-prettier": "^5.1.3",
48+
"husky": "^9.0.11",
49+
"jest": "^29.7.0",
50+
"lint-staged": "^15.2.2",
51+
"prettier": "^3.2.5",
52+
"supertest": "^6.3.4",
53+
"vite": "^5.2.8"
5554
},
5655
"dependencies": {
5756
"@apollo/client": "^3.9.11",
58-
"cors": "^2.8.4",
59-
"express": "^4.17.2",
57+
"@graphql-tools/schema": "^10.0.3",
58+
"cors": "^2.8.5",
59+
"express": "^4.17.3",
6060
"express-graphql": "^0.9.0",
61-
"graphql": "^14.5.8",
62-
"graphql-tag": "^2.10.1",
63-
"graphql-tools": "^4.0.5",
64-
"graphql-type-json": "^0.3.0",
65-
"inflection": "^1.12.0",
61+
"graphql": "^16.8.1",
62+
"graphql-tag": "^2.12.6",
63+
"graphql-type-json": "^0.3.2",
64+
"inflection": "^3.0.0",
6665
"lodash.merge": "^4.6.2",
6766
"reify": "^0.20.12",
68-
"xhr-mock": "^2.5.0"
67+
"xhr-mock": "^2.5.1"
6968
},
7069
"bin": {
7170
"json-graphql-server": "bin/json-graphql-server.js"

src/introspection/getSchemaFromData.spec.js

+35-74
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
GraphQLString,
88
} from 'graphql';
99
import getSchemaFromData from './getSchemaFromData';
10+
import e from 'cors';
1011

1112
const data = {
1213
posts: [
@@ -128,12 +129,10 @@ test('creates three query fields per data type', () => {
128129
const queries = getSchemaFromData(data).getQueryType().getFields();
129130
expect(queries['Post'].type.name).toEqual(PostType.name);
130131
expect(queries['Post'].args).toEqual([
131-
{
132-
defaultValue: undefined,
133-
description: null,
132+
expect.objectContaining({
134133
name: 'id',
135134
type: new GraphQLNonNull(GraphQLID),
136-
},
135+
}),
137136
]);
138137
expect(queries['allPosts'].type.toString()).toEqual('[Post]');
139138
expect(queries['allPosts'].args[0].name).toEqual('page');
@@ -150,12 +149,10 @@ test('creates three query fields per data type', () => {
150149

151150
expect(queries['User'].type.name).toEqual(UserType.name);
152151
expect(queries['User'].args).toEqual([
153-
{
154-
defaultValue: undefined,
155-
description: null,
152+
expect.objectContaining({
156153
name: 'id',
157154
type: new GraphQLNonNull(GraphQLID),
158-
},
155+
}),
159156
]);
160157
expect(queries['allUsers'].type.toString()).toEqual('[User]');
161158
expect(queries['allUsers'].args[0].name).toEqual('page');
@@ -175,93 +172,69 @@ test('creates three mutation fields per data type', () => {
175172
const mutations = getSchemaFromData(data).getMutationType().getFields();
176173
expect(mutations['createPost'].type.name).toEqual(PostType.name);
177174
expect(mutations['createPost'].args).toEqual([
178-
{
175+
expect.objectContaining({
179176
name: 'title',
180177
type: new GraphQLNonNull(GraphQLString),
181-
defaultValue: undefined,
182-
description: null,
183-
},
184-
{
178+
}),
179+
expect.objectContaining({
185180
name: 'views',
186181
type: new GraphQLNonNull(GraphQLInt),
187-
defaultValue: undefined,
188-
description: null,
189-
},
190-
{
182+
}),
183+
expect.objectContaining({
191184
name: 'user_id',
192185
type: new GraphQLNonNull(GraphQLID),
193-
defaultValue: undefined,
194-
description: null,
195-
},
186+
}),
196187
]);
197188
expect(mutations['updatePost'].type.name).toEqual(PostType.name);
198189
expect(mutations['updatePost'].args).toEqual([
199-
{
190+
expect.objectContaining({
200191
name: 'id',
201192
type: new GraphQLNonNull(GraphQLID),
202-
defaultValue: undefined,
203-
description: null,
204-
},
205-
{
193+
}),
194+
expect.objectContaining({
206195
name: 'title',
207196
type: GraphQLString,
208-
defaultValue: undefined,
209-
description: null,
210-
},
211-
{
197+
}),
198+
expect.objectContaining({
212199
name: 'views',
213200
type: GraphQLInt,
214-
defaultValue: undefined,
215-
description: null,
216-
},
217-
{
201+
}),
202+
expect.objectContaining({
218203
name: 'user_id',
219204
type: GraphQLID,
220-
defaultValue: undefined,
221-
description: null,
222-
},
205+
}),
223206
]);
224207
expect(mutations['removePost'].type.name).toEqual(PostType.name);
225208
expect(mutations['removePost'].args).toEqual([
226-
{
209+
expect.objectContaining({
227210
name: 'id',
228211
type: new GraphQLNonNull(GraphQLID),
229-
defaultValue: undefined,
230-
description: null,
231-
},
212+
}),
232213
]);
233214
expect(mutations['createUser'].type.name).toEqual(UserType.name);
234215
expect(mutations['createUser'].args).toEqual([
235-
{
216+
expect.objectContaining({
236217
name: 'name',
237218
type: new GraphQLNonNull(GraphQLString),
238-
defaultValue: undefined,
239-
description: null,
240-
},
219+
}),
241220
]);
242221
expect(mutations['updateUser'].type.name).toEqual(UserType.name);
243222
expect(mutations['updateUser'].args).toEqual([
244-
{
223+
expect.objectContaining({
245224
name: 'id',
246225
type: new GraphQLNonNull(GraphQLID),
247-
defaultValue: undefined,
248-
description: null,
249-
},
250-
{
226+
}),
227+
expect.objectContaining({
251228
name: 'name',
252229
type: GraphQLString,
253-
defaultValue: undefined,
254-
description: null,
255-
},
230+
}),
256231
]);
257232
expect(mutations['removeUser'].type.name).toEqual(UserType.name);
258233
expect(mutations['removeUser'].args).toEqual([
259-
{
260-
defaultValue: undefined,
261-
description: null,
234+
expect.objectContaining({
262235
name: 'id',
263236
type: new GraphQLNonNull(GraphQLID),
264-
},
237+
}),
265238
]);
266239
});
267240

@@ -270,30 +243,18 @@ test('creates the mutation *Input type for createMany', () => {
270243
const createManyPostInputType = mutations['createManyPost'].args[0].type;
271244
expect(createManyPostInputType.toString()).toEqual('[PostInput]');
272245
expect(createManyPostInputType.ofType.getFields()).toEqual({
273-
title: {
246+
title: expect.objectContaining({
274247
type: new GraphQLNonNull(GraphQLString),
275248
name: 'title',
276-
astNode: undefined,
277-
defaultValue: undefined,
278-
description: undefined,
279-
extensions: undefined,
280-
},
281-
views: {
249+
}),
250+
views: expect.objectContaining({
282251
type: new GraphQLNonNull(GraphQLInt),
283252
name: 'views',
284-
astNode: undefined,
285-
defaultValue: undefined,
286-
description: undefined,
287-
extensions: undefined,
288-
},
289-
user_id: {
253+
}),
254+
user_id: expect.objectContaining({
290255
type: new GraphQLNonNull(GraphQLID),
291256
name: 'user_id',
292-
astNode: undefined,
293-
defaultValue: undefined,
294-
description: undefined,
295-
extensions: undefined,
296-
},
257+
}),
297258
});
298259
});
299260

src/schemaBuilder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { makeExecutableSchema } from 'graphql-tools';
1+
import { makeExecutableSchema } from '@graphql-tools/schema';
22
import { printSchema } from 'graphql';
33
import getSchemaFromData from './introspection/getSchemaFromData';
44
import resolver from './resolver';

0 commit comments

Comments
 (0)