@envelop/apollo-server-errors 3.4.0-alpha-c0cc559.0 → 3.4.0-alpha-e9434aa.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/{index.js → cjs/index.js} +7 -10
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +8 -7
- package/package.json +33 -12
- package/{index.d.ts → typings/index.d.ts} +0 -0
- package/README.md +0 -26
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const apolloServerErrors = require('apollo-server-errors');
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useApolloServerErrors = void 0;
|
|
4
|
+
const core_1 = require("@envelop/core");
|
|
5
|
+
const apollo_server_errors_1 = require("apollo-server-errors");
|
|
8
6
|
const makeHandleResult = (options = {}) => ({ result, setResult }) => {
|
|
9
7
|
if (result.errors && result.errors.length > 0) {
|
|
10
8
|
setResult({
|
|
@@ -13,7 +11,7 @@ const makeHandleResult = (options = {}) => ({ result, setResult }) => {
|
|
|
13
11
|
// Type 'ApolloError[]' is not assignable to type 'readonly GraphQLError[]'. Property '[Symbol.toStringTag]' is missing in type 'ApolloError' but required in type 'GraphQLError'.
|
|
14
12
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
13
|
// @ts-ignore
|
|
16
|
-
errors:
|
|
14
|
+
errors: (0, apollo_server_errors_1.formatApolloErrors)(result.errors, {
|
|
17
15
|
debug: options.debug,
|
|
18
16
|
formatter: options.formatter,
|
|
19
17
|
}),
|
|
@@ -26,11 +24,10 @@ const useApolloServerErrors = (options = {}) => {
|
|
|
26
24
|
const handleResult = makeHandleResult(options);
|
|
27
25
|
return {
|
|
28
26
|
onExecuteDone(payload) {
|
|
29
|
-
return
|
|
27
|
+
return (0, core_1.handleStreamOrSingleExecutionResult)(payload, handleResult);
|
|
30
28
|
},
|
|
31
29
|
};
|
|
32
30
|
},
|
|
33
31
|
};
|
|
34
32
|
};
|
|
35
|
-
|
|
36
33
|
exports.useApolloServerErrors = useApolloServerErrors;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useApolloServerErrors = void 0;
|
|
4
|
+
const core_1 = require("@envelop/core");
|
|
5
|
+
const apollo_server_errors_1 = require("apollo-server-errors");
|
|
4
6
|
const makeHandleResult = (options = {}) => ({ result, setResult }) => {
|
|
5
7
|
if (result.errors && result.errors.length > 0) {
|
|
6
8
|
setResult({
|
|
@@ -9,7 +11,7 @@ const makeHandleResult = (options = {}) => ({ result, setResult }) => {
|
|
|
9
11
|
// Type 'ApolloError[]' is not assignable to type 'readonly GraphQLError[]'. Property '[Symbol.toStringTag]' is missing in type 'ApolloError' but required in type 'GraphQLError'.
|
|
10
12
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
13
|
// @ts-ignore
|
|
12
|
-
errors: formatApolloErrors(result.errors, {
|
|
14
|
+
errors: (0, apollo_server_errors_1.formatApolloErrors)(result.errors, {
|
|
13
15
|
debug: options.debug,
|
|
14
16
|
formatter: options.formatter,
|
|
15
17
|
}),
|
|
@@ -22,11 +24,10 @@ const useApolloServerErrors = (options = {}) => {
|
|
|
22
24
|
const handleResult = makeHandleResult(options);
|
|
23
25
|
return {
|
|
24
26
|
onExecuteDone(payload) {
|
|
25
|
-
return handleStreamOrSingleExecutionResult(payload, handleResult);
|
|
27
|
+
return (0, core_1.handleStreamOrSingleExecutionResult)(payload, handleResult);
|
|
26
28
|
},
|
|
27
29
|
};
|
|
28
30
|
},
|
|
29
31
|
};
|
|
30
32
|
};
|
|
31
|
-
|
|
32
|
-
export { useApolloServerErrors };
|
|
33
|
+
exports.useApolloServerErrors = useApolloServerErrors;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/apollo-server-errors",
|
|
3
|
-
"version": "3.4.0-alpha-
|
|
3
|
+
"version": "3.4.0-alpha-e9434aa.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "2.4.0-alpha-
|
|
6
|
+
"@envelop/core": "2.4.0-alpha-e9434aa.0",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
@@ -11,26 +11,47 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/n1ru4l/envelop.git",
|
|
15
15
|
"directory": "packages/plugins/apollo-server-errors"
|
|
16
16
|
},
|
|
17
17
|
"author": "Dotan Simha <dotansimha@gmail.com>",
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"main": "index.js",
|
|
20
|
-
"module": "index.
|
|
21
|
-
"typings": "index.d.ts",
|
|
19
|
+
"main": "cjs/index.js",
|
|
20
|
+
"module": "esm/index.js",
|
|
21
|
+
"typings": "typings/index.d.ts",
|
|
22
22
|
"typescript": {
|
|
23
|
-
"definition": "index.d.ts"
|
|
23
|
+
"definition": "typings/index.d.ts"
|
|
24
24
|
},
|
|
25
|
+
"type": "module",
|
|
25
26
|
"exports": {
|
|
26
27
|
".": {
|
|
27
|
-
"require":
|
|
28
|
-
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./typings/index.d.ts",
|
|
30
|
+
"default": "./cjs/index.js"
|
|
31
|
+
},
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./typings/index.d.ts",
|
|
34
|
+
"default": "./esm/index.js"
|
|
35
|
+
},
|
|
36
|
+
"default": {
|
|
37
|
+
"types": "./typings/index.d.ts",
|
|
38
|
+
"default": "./esm/index.js"
|
|
39
|
+
}
|
|
29
40
|
},
|
|
30
41
|
"./*": {
|
|
31
|
-
"require":
|
|
32
|
-
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./typings/*.d.ts",
|
|
44
|
+
"default": "./cjs/*.js"
|
|
45
|
+
},
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./typings/*.d.ts",
|
|
48
|
+
"default": "./esm/*.js"
|
|
49
|
+
},
|
|
50
|
+
"default": {
|
|
51
|
+
"types": "./typings/*.d.ts",
|
|
52
|
+
"default": "./esm/*.js"
|
|
53
|
+
}
|
|
33
54
|
},
|
|
34
55
|
"./package.json": "./package.json"
|
|
35
56
|
}
|
|
36
|
-
}
|
|
57
|
+
}
|
|
File without changes
|
package/README.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
## `@envelop/apollo-server-errors`
|
|
2
|
-
|
|
3
|
-
This plugin exposes the same error structure as `apollo-server`. Use this plugin if you are moving to Envelop, and wish to get a compatibility layer for your errors, to make sure the clients receive the same output.
|
|
4
|
-
|
|
5
|
-
## Getting Started
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
yarn add @envelop/apollo-server-errors
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage Example
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { envelop } from '@envelop/core';
|
|
15
|
-
import { useApolloServerErrors } from '@envelop/apollo-server-errors';
|
|
16
|
-
|
|
17
|
-
const getEnveloped = envelop({
|
|
18
|
-
plugins: [
|
|
19
|
-
// ... other plugins ...
|
|
20
|
-
useApolloServerErrors({ // All fields are optional, and should match what you pass today to ApolloServer
|
|
21
|
-
debug: true, //
|
|
22
|
-
formatError: () => ...
|
|
23
|
-
}),
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
```
|