@ocap/gql 1.30.26 → 1.31.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/esm/http.mjs +27 -6
- package/lib/http.cjs +27 -6
- package/package.json +3 -3
package/esm/http.mjs
CHANGED
|
@@ -217,11 +217,27 @@ const resolvers = [
|
|
|
217
217
|
}
|
|
218
218
|
];
|
|
219
219
|
const createResolvers = (resolver) => resolvers.reduce((acc, { fn, dataKey }) => {
|
|
220
|
-
acc[fn] = (args, ctx) =>
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
acc[fn] = async (args, ctx) => {
|
|
221
|
+
const res = await wrapResolver(fn, dataKey, () => {
|
|
222
|
+
const method = resolver[fn];
|
|
223
|
+
if (typeof method === "function") return method.call(resolver, args, formatContext(ctx));
|
|
224
|
+
return null;
|
|
225
|
+
});
|
|
226
|
+
if (fn === "sendTx") {
|
|
227
|
+
if (res.hash && typeof res.hash === "object" && "hash" in res.hash) {
|
|
228
|
+
const inner = res.hash;
|
|
229
|
+
res.hash = inner.hash;
|
|
230
|
+
if (inner.warning !== void 0) res.warning = inner.warning;
|
|
231
|
+
} else if (typeof res.hash === "string") {
|
|
232
|
+
const getWarning = resolver.getTxSecurityWarning;
|
|
233
|
+
if (typeof getWarning === "function") {
|
|
234
|
+
const warning = getWarning.call(resolver, res.hash);
|
|
235
|
+
if (warning !== void 0) res.warning = warning;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return res;
|
|
240
|
+
};
|
|
225
241
|
return acc;
|
|
226
242
|
}, {});
|
|
227
243
|
const defaultErrorHandler = (err) => {
|
|
@@ -582,13 +598,18 @@ const createGraphQLEngine = ({ resolver = {}, onError = defaultErrorHandler, gra
|
|
|
582
598
|
const formatGraphQLError = (err) => {
|
|
583
599
|
onError(err);
|
|
584
600
|
const includeStack = showStack && process.env.NODE_ENV !== "production";
|
|
585
|
-
|
|
601
|
+
const formatted = {
|
|
586
602
|
code: get(err, "originalError.code", "INTERNAL"),
|
|
587
603
|
message: err.message,
|
|
588
604
|
locations: err.locations || [],
|
|
589
605
|
stack: includeStack ? get(err, "originalError.stack", "").split("\n") : [],
|
|
590
606
|
path: err.path
|
|
591
607
|
};
|
|
608
|
+
const warning = get(err, "originalError.warning") ?? get(err, "originalError.props.warning");
|
|
609
|
+
if (warning !== void 0) formatted.warning = warning;
|
|
610
|
+
const slashEvidence = get(err, "originalError.slashEvidence") ?? get(err, "originalError.props.slashEvidence");
|
|
611
|
+
if (slashEvidence !== void 0) formatted.slashEvidence = slashEvidence;
|
|
612
|
+
return formatted;
|
|
592
613
|
};
|
|
593
614
|
const formatAnyError = (input) => {
|
|
594
615
|
const message = typeof input === "string" ? input : input.message;
|
package/lib/http.cjs
CHANGED
|
@@ -220,11 +220,27 @@ const resolvers = [
|
|
|
220
220
|
}
|
|
221
221
|
];
|
|
222
222
|
const createResolvers = (resolver) => resolvers.reduce((acc, { fn, dataKey }) => {
|
|
223
|
-
acc[fn] = (args, ctx) =>
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
acc[fn] = async (args, ctx) => {
|
|
224
|
+
const res = await wrapResolver(fn, dataKey, () => {
|
|
225
|
+
const method = resolver[fn];
|
|
226
|
+
if (typeof method === "function") return method.call(resolver, args, formatContext(ctx));
|
|
227
|
+
return null;
|
|
228
|
+
});
|
|
229
|
+
if (fn === "sendTx") {
|
|
230
|
+
if (res.hash && typeof res.hash === "object" && "hash" in res.hash) {
|
|
231
|
+
const inner = res.hash;
|
|
232
|
+
res.hash = inner.hash;
|
|
233
|
+
if (inner.warning !== void 0) res.warning = inner.warning;
|
|
234
|
+
} else if (typeof res.hash === "string") {
|
|
235
|
+
const getWarning = resolver.getTxSecurityWarning;
|
|
236
|
+
if (typeof getWarning === "function") {
|
|
237
|
+
const warning = getWarning.call(resolver, res.hash);
|
|
238
|
+
if (warning !== void 0) res.warning = warning;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return res;
|
|
243
|
+
};
|
|
228
244
|
return acc;
|
|
229
245
|
}, {});
|
|
230
246
|
const defaultErrorHandler = (err) => {
|
|
@@ -585,13 +601,18 @@ const createGraphQLEngine = ({ resolver = {}, onError = defaultErrorHandler, gra
|
|
|
585
601
|
const formatGraphQLError = (err) => {
|
|
586
602
|
onError(err);
|
|
587
603
|
const includeStack = showStack && process.env.NODE_ENV !== "production";
|
|
588
|
-
|
|
604
|
+
const formatted = {
|
|
589
605
|
code: (0, lodash_get.default)(err, "originalError.code", "INTERNAL"),
|
|
590
606
|
message: err.message,
|
|
591
607
|
locations: err.locations || [],
|
|
592
608
|
stack: includeStack ? (0, lodash_get.default)(err, "originalError.stack", "").split("\n") : [],
|
|
593
609
|
path: err.path
|
|
594
610
|
};
|
|
611
|
+
const warning = (0, lodash_get.default)(err, "originalError.warning") ?? (0, lodash_get.default)(err, "originalError.props.warning");
|
|
612
|
+
if (warning !== void 0) formatted.warning = warning;
|
|
613
|
+
const slashEvidence = (0, lodash_get.default)(err, "originalError.slashEvidence") ?? (0, lodash_get.default)(err, "originalError.props.slashEvidence");
|
|
614
|
+
if (slashEvidence !== void 0) formatted.slashEvidence = slashEvidence;
|
|
615
|
+
return formatted;
|
|
595
616
|
};
|
|
596
617
|
const formatAnyError = (input) => {
|
|
597
618
|
const message = typeof input === "string" ? input : input.message;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.31.0",
|
|
7
7
|
"description": "Resolver middleware for ocap adapters",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
],
|
|
52
52
|
"license": "MIT",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@arcblock/ws": "1.
|
|
55
|
-
"@ocap/schema": "1.
|
|
54
|
+
"@arcblock/ws": "1.31.0",
|
|
55
|
+
"@ocap/schema": "1.31.0",
|
|
56
56
|
"graphql": "^16.13.2",
|
|
57
57
|
"lodash": "^4.17.23"
|
|
58
58
|
},
|