graphql-http 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -9
- package/lib/audits/common.d.mts +15 -0
- package/lib/audits/common.d.ts +15 -0
- package/lib/audits/server.js +54 -65
- package/lib/audits/server.mjs +54 -65
- package/lib/audits/utils.d.mts +1 -1
- package/lib/audits/utils.d.ts +1 -1
- package/lib/audits/utils.js +4 -1
- package/lib/audits/utils.mjs +4 -1
- package/lib/handler.d.mts +14 -1
- package/lib/handler.d.ts +14 -1
- package/lib/handler.js +9 -2
- package/lib/handler.mjs +10 -3
- package/package.json +19 -19
- package/umd/graphql-http.min.js.gz +0 -0
package/lib/handler.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* handler
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
|
-
import { validate as graphqlValidate, execute as graphqlExecute, parse as graphqlParse, getOperationAST as graphqlGetOperationAST, GraphQLError, } from 'graphql';
|
|
6
|
+
import { validate as graphqlValidate, specifiedRules, execute as graphqlExecute, parse as graphqlParse, getOperationAST as graphqlGetOperationAST, GraphQLError, } from 'graphql';
|
|
7
7
|
import { areGraphQLErrors, isAsyncIterable, isExecutionResult, isGraphQLError, isObject, } from './utils.mjs';
|
|
8
8
|
/**
|
|
9
9
|
* Checks whether the passed value is the `graphql-http` server agnostic response.
|
|
@@ -72,7 +72,7 @@ export function isResponse(val) {
|
|
|
72
72
|
* @category Server
|
|
73
73
|
*/
|
|
74
74
|
export function createHandler(options) {
|
|
75
|
-
const { schema, context, validate = graphqlValidate, execute = graphqlExecute, parse = graphqlParse, getOperationAST = graphqlGetOperationAST, rootValue, onSubscribe, onOperation, } = options;
|
|
75
|
+
const { schema, context, validate = graphqlValidate, validationRules = [], execute = graphqlExecute, parse = graphqlParse, getOperationAST = graphqlGetOperationAST, rootValue, onSubscribe, onOperation, } = options;
|
|
76
76
|
return async function handler(req) {
|
|
77
77
|
var _a, _b;
|
|
78
78
|
const method = req.method;
|
|
@@ -222,7 +222,14 @@ export function createHandler(options) {
|
|
|
222
222
|
else {
|
|
223
223
|
args = Object.assign(Object.assign({}, argsWithoutSchema), { schema });
|
|
224
224
|
}
|
|
225
|
-
|
|
225
|
+
let rules = specifiedRules;
|
|
226
|
+
if (typeof validationRules === 'function') {
|
|
227
|
+
rules = await validationRules(req, args, specifiedRules);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
rules = [...rules, ...validationRules];
|
|
231
|
+
}
|
|
232
|
+
const validationErrs = validate(args.schema, args.document, rules);
|
|
226
233
|
if (validationErrs.length) {
|
|
227
234
|
return makeResponse(validationErrs, acceptedMediaType);
|
|
228
235
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-http",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Simple, pluggable, zero-dependency, GraphQL over HTTP Protocol compliant server and client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=12"
|
|
26
26
|
},
|
|
27
|
-
"packageManager": "yarn@3.
|
|
27
|
+
"packageManager": "yarn@3.4.1",
|
|
28
28
|
"main": "lib/index.js",
|
|
29
29
|
"module": "lib/index.mjs",
|
|
30
30
|
"browser": "umd/graphql-http.js",
|
|
@@ -102,37 +102,37 @@
|
|
|
102
102
|
"@babel/plugin-proposal-optional-chaining": "^7.20.7",
|
|
103
103
|
"@babel/preset-env": "^7.20.2",
|
|
104
104
|
"@babel/preset-typescript": "^7.18.6",
|
|
105
|
-
"@rollup/plugin-terser": "^0.
|
|
105
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
106
106
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
107
107
|
"@semantic-release/changelog": "^6.0.2",
|
|
108
108
|
"@semantic-release/git": "^10.0.1",
|
|
109
|
-
"@types/eslint": "^8.
|
|
110
|
-
"@types/express": "^4.17.
|
|
109
|
+
"@types/eslint": "^8.21.0",
|
|
110
|
+
"@types/express": "^4.17.17",
|
|
111
111
|
"@types/glob": "^8.0.1",
|
|
112
|
-
"@types/jest": "^29.
|
|
112
|
+
"@types/jest": "^29.4.0",
|
|
113
113
|
"@types/koa": "^2.13.5",
|
|
114
114
|
"@types/koa-mount": "^4.0.2",
|
|
115
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
116
|
-
"@typescript-eslint/parser": "^5.
|
|
117
|
-
"@whatwg-node/fetch": "^0.
|
|
118
|
-
"babel-jest": "^29.
|
|
119
|
-
"eslint": "^8.
|
|
115
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
116
|
+
"@typescript-eslint/parser": "^5.51.0",
|
|
117
|
+
"@whatwg-node/fetch": "^0.7.0",
|
|
118
|
+
"babel-jest": "^29.4.2",
|
|
119
|
+
"eslint": "^8.33.0",
|
|
120
120
|
"eslint-config-prettier": "^8.6.0",
|
|
121
121
|
"express": "^4.18.2",
|
|
122
|
-
"fastify": "^4.
|
|
122
|
+
"fastify": "^4.12.0",
|
|
123
123
|
"graphql": "^16.6.0",
|
|
124
|
-
"jest": "^29.
|
|
125
|
-
"jest-jasmine2": "^29.
|
|
124
|
+
"jest": "^29.4.2",
|
|
125
|
+
"jest-jasmine2": "^29.4.2",
|
|
126
126
|
"koa": "^2.14.1",
|
|
127
127
|
"koa-mount": "^4.0.0",
|
|
128
128
|
"node-fetch": "^3.3.0",
|
|
129
|
-
"prettier": "^2.8.
|
|
130
|
-
"rollup": "^3.
|
|
131
|
-
"semantic-release": "^20.0
|
|
132
|
-
"tslib": "^2.
|
|
129
|
+
"prettier": "^2.8.4",
|
|
130
|
+
"rollup": "^3.14.0",
|
|
131
|
+
"semantic-release": "^20.1.0",
|
|
132
|
+
"tslib": "^2.5.0",
|
|
133
133
|
"typedoc": "^0.23.24",
|
|
134
134
|
"typedoc-plugin-markdown": "^3.14.0",
|
|
135
|
-
"typescript": "^4.9.
|
|
135
|
+
"typescript": "^4.9.5"
|
|
136
136
|
},
|
|
137
137
|
"resolutions": {
|
|
138
138
|
"npm/libnpmversion": "^3.0.6"
|
|
Binary file
|