Skip to content

Commit 7f32987

Browse files
authored
Merge pull request #169 from marmelab/update-deps
Update tooling
2 parents 918a426 + 2ad5865 commit 7f32987

18 files changed

+2924
-5891
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Use Node.js LTS
1616
uses: actions/setup-node@v1
1717
with:
18-
node-version: '14.x'
18+
node-version: '20.x'
1919
- uses: bahmutov/npm-install@v1
2020
with:
2121
install-command: yarn --immutable

.gitignore

Lines changed: 1 addition & 1 deletion
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

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

Makefile

Lines changed: 6 additions & 4 deletions
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,6 @@ 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
29+
@yarn vite build -c ./vite.config.node.js
30+
@yarn vite build -c ./vite.config.umd.js

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ Then use the `jsonGraphqlExpress` express middleware:
448448

449449
```js
450450
import express from 'express';
451-
import jsonGraphqlExpress from 'json-graphql-server';
451+
import jsonGraphqlExpress from 'json-graphql-server/node';
452452

453453
const PORT = 3000;
454454
const app = express();
@@ -469,7 +469,7 @@ Useful when using XMLHttpRequest directly or libraries such as [axios](https://w
469469
Add a `script` tag referencing the library:
470470

471471
```html
472-
<script src="../lib/json-graphql-server.client.min.js"></script>
472+
<script src="../dist/json-graphql-server.umd.js"></script>
473473
```
474474

475475
It will expose the `JsonGraphqlServer` as a global object:

babel.config.js

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

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

Lines changed: 1 addition & 1 deletion
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-node').default;
77

88
var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json';
99
var data = require(path.join(process.cwd(), dataFilePath));

example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>
77
<button id="button">Load posts</button>
8-
<script src="../lib/json-graphql-server.client.min.js"></script>
8+
<script src="../dist/json-graphql-server.umd.cjs"></script>
99
<script type="text/javascript">
1010
window.addEventListener('load', function() {
1111
const data = {

package.json

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
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.cjs",
6+
"module": "./dist/json-graphql-server.js",
7+
"exports": {
8+
".": {
9+
"import": "./dist/json-graphql-server.js",
10+
"require": "./dist/json-graphql-server.cjs"
11+
},
12+
"./node": {
13+
"import": "./dist/json-graphql-server-node.js",
14+
"require": "./dist/json-graphql-server-node.cjs"
15+
}
16+
},
617
"repository": "[email protected]:marmelab/json-graphql-server.git",
718
"authors": [
819
"François Zaninotto",
@@ -30,44 +41,36 @@
3041
]
3142
},
3243
"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",
44+
"@types/jest": "^29.5.12",
3945
"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"
46+
"babel-jest": "^29.7.0",
47+
"eslint": "^9.0.0",
48+
"eslint-config-prettier": "^9.1.0",
49+
"eslint-plugin-import": "^2.29.1",
50+
"eslint-plugin-jest": "^28.2.0",
51+
"eslint-plugin-prettier": "^5.1.3",
52+
"husky": "^9.0.11",
53+
"jest": "^29.7.0",
54+
"lint-staged": "^15.2.2",
55+
"prettier": "^3.2.5",
56+
"supertest": "^6.3.4",
57+
"vite": "^5.2.8"
5558
},
5659
"dependencies": {
5760
"@apollo/client": "^3.9.11",
58-
"cors": "^2.8.4",
59-
"express": "^4.17.2",
61+
"@graphql-tools/schema": "^10.0.3",
62+
"cors": "^2.8.5",
63+
"express": "^4.17.3",
6064
"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",
65+
"graphql": "^16.8.1",
66+
"graphql-tag": "^2.12.6",
67+
"graphql-type-json": "^0.3.2",
68+
"inflection": "^3.0.0",
6669
"lodash.merge": "^4.6.2",
6770
"reify": "^0.20.12",
68-
"xhr-mock": "^2.5.0"
71+
"xhr-mock": "^2.5.1"
6972
},
7073
"bin": {
7174
"json-graphql-server": "bin/json-graphql-server.js"
7275
}
73-
}
76+
}

src/handleRequest.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ export default function (data) {
5151

5252
const query = JSON.parse(body);
5353

54-
return graphql(
54+
return graphql({
5555
schema,
56-
query.query,
57-
undefined,
58-
undefined,
59-
query.variables
60-
).then(
56+
source: query.query,
57+
variableValues: query.variables
58+
}).then(
6159
(result) => ({
6260
status: 200,
6361
headers: { 'Content-Type': 'application/json' },

0 commit comments

Comments
 (0)