@envelop/core 2.4.2 → 2.5.0-alpha-fdf5e62a.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.
@@ -8,14 +8,23 @@ const makeHandleResult = (errorHandler) => ({ result, args }) => {
8
8
  errorHandler(result.errors, args);
9
9
  }
10
10
  };
11
- const useErrorHandler = (errorHandler) => ({
12
- onExecute() {
13
- const handleResult = makeHandleResult(errorHandler);
14
- return {
15
- onExecuteDone(payload) {
16
- return (0, utils_js_1.handleStreamOrSingleExecutionResult)(payload, handleResult);
17
- },
18
- };
19
- },
20
- });
11
+ const useErrorHandler = (errorHandler) => {
12
+ const handleResult = makeHandleResult(errorHandler);
13
+ return {
14
+ onExecute() {
15
+ return {
16
+ onExecuteDone(payload) {
17
+ return (0, utils_js_1.handleStreamOrSingleExecutionResult)(payload, handleResult);
18
+ },
19
+ };
20
+ },
21
+ onSubscribe() {
22
+ return {
23
+ onSubscribeResult(payload) {
24
+ return (0, utils_js_1.handleStreamOrSingleExecutionResult)(payload, handleResult);
25
+ },
26
+ };
27
+ },
28
+ };
29
+ };
21
30
  exports.useErrorHandler = useErrorHandler;
@@ -65,6 +65,9 @@ const useMaskedErrors = (opts) => {
65
65
  : undefined,
66
66
  onPluginInit(context) {
67
67
  context.registerContextErrorHandler(({ error, setError }) => {
68
+ if (error instanceof graphql_1.GraphQLError === false && error instanceof Error) {
69
+ error = new graphql_1.GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
70
+ }
68
71
  setError(format(error, message, isDev));
69
72
  });
70
73
  },
@@ -5,13 +5,22 @@ const makeHandleResult = (errorHandler) => ({ result, args }) => {
5
5
  errorHandler(result.errors, args);
6
6
  }
7
7
  };
8
- export const useErrorHandler = (errorHandler) => ({
9
- onExecute() {
10
- const handleResult = makeHandleResult(errorHandler);
11
- return {
12
- onExecuteDone(payload) {
13
- return handleStreamOrSingleExecutionResult(payload, handleResult);
14
- },
15
- };
16
- },
17
- });
8
+ export const useErrorHandler = (errorHandler) => {
9
+ const handleResult = makeHandleResult(errorHandler);
10
+ return {
11
+ onExecute() {
12
+ return {
13
+ onExecuteDone(payload) {
14
+ return handleStreamOrSingleExecutionResult(payload, handleResult);
15
+ },
16
+ };
17
+ },
18
+ onSubscribe() {
19
+ return {
20
+ onSubscribeResult(payload) {
21
+ return handleStreamOrSingleExecutionResult(payload, handleResult);
22
+ },
23
+ };
24
+ },
25
+ };
26
+ };
@@ -60,6 +60,9 @@ export const useMaskedErrors = (opts) => {
60
60
  : undefined,
61
61
  onPluginInit(context) {
62
62
  context.registerContextErrorHandler(({ error, setError }) => {
63
+ if (error instanceof GraphQLError === false && error instanceof Error) {
64
+ error = new GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
65
+ }
63
66
  setError(format(error, message, isDev));
64
67
  });
65
68
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "2.4.2",
3
+ "version": "2.5.0-alpha-fdf5e62a.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"