@ocap/gql 1.16.15 → 1.17.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/lib/index.js +19 -1
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -88,6 +88,7 @@ const defaultErrorHandler = (err) => {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
const MAX_BATCH_SIZE = 40;
|
|
91
92
|
const createHttpHandler = ({ resolver, onError = defaultErrorHandler, graphiql = true }) =>
|
|
92
93
|
graphqlHTTP({
|
|
93
94
|
schema: buildSchema(schemaSource),
|
|
@@ -95,7 +96,24 @@ const createHttpHandler = ({ resolver, onError = defaultErrorHandler, graphiql =
|
|
|
95
96
|
graphiql,
|
|
96
97
|
// NOTE: following is required because of following gql query validation issue
|
|
97
98
|
// https://stackoverflow.com/questions/56695262/graphql-error-fieldsconflict-fields-have-different-list-shapes
|
|
98
|
-
customValidateFn: () =>
|
|
99
|
+
customValidateFn: (schema, query) => {
|
|
100
|
+
const operations = query.definitions
|
|
101
|
+
.map((x) => {
|
|
102
|
+
const selections = get(x, 'selectionSet.selections') || [];
|
|
103
|
+
const names = selections.map((y) => get(y, 'name.value'));
|
|
104
|
+
return names;
|
|
105
|
+
})
|
|
106
|
+
.reduce((arr, names) => {
|
|
107
|
+
arr.push(...names);
|
|
108
|
+
return arr;
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
if (operations.length > MAX_BATCH_SIZE) {
|
|
112
|
+
throw new Error(`Batch query size exceeded allowed maximum batch size of ${MAX_BATCH_SIZE}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
99
117
|
|
|
100
118
|
// format custom error code
|
|
101
119
|
customFormatErrorFn: (err) => {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.17.0",
|
|
7
7
|
"description": "Resolver middleware for ocap adapters",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@arcblock/ws": "1.
|
|
26
|
-
"@ocap/schema": "1.
|
|
25
|
+
"@arcblock/ws": "1.17.0",
|
|
26
|
+
"@ocap/schema": "1.17.0",
|
|
27
27
|
"debug": "^4.3.3",
|
|
28
28
|
"express-graphql": "^0.12.0",
|
|
29
29
|
"graphql": "14.6.0",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"express": "^4.17.1",
|
|
34
34
|
"jest": "^27.3.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f0944b60a5fb4115e1a3727bb07f68174bc56c5c"
|
|
37
37
|
}
|