@envelop/apollo-server-errors 4.0.0-alpha-d0d0776.0 → 4.0.0-alpha-5b6bfa8.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 +9 -8
- package/{index.js → cjs/index.js} +7 -10
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +1 -4
- package/package.json +26 -17
- /package/{index.d.ts → typings/index.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -11,16 +11,17 @@ yarn add @envelop/apollo-server-errors
|
|
|
11
11
|
## Usage Example
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { envelop } from '@envelop/core'
|
|
15
|
-
import { useApolloServerErrors } from '@envelop/apollo-server-errors'
|
|
14
|
+
import { envelop } from '@envelop/core'
|
|
15
|
+
import { useApolloServerErrors } from '@envelop/apollo-server-errors'
|
|
16
16
|
|
|
17
17
|
const getEnveloped = envelop({
|
|
18
18
|
plugins: [
|
|
19
19
|
// ... other plugins ...
|
|
20
|
-
useApolloServerErrors({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
useApolloServerErrors({
|
|
21
|
+
// All fields are optional, and should match what you pass today to ApolloServer
|
|
22
|
+
debug: true, //
|
|
23
|
+
formatError: () => {}
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
})
|
|
26
27
|
```
|
|
@@ -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,5 @@
|
|
|
1
1
|
import { handleStreamOrSingleExecutionResult } from '@envelop/core';
|
|
2
2
|
import { formatApolloErrors } from 'apollo-server-errors';
|
|
3
|
-
|
|
4
3
|
const makeHandleResult = (options = {}) => ({ result, setResult }) => {
|
|
5
4
|
if (result.errors && result.errors.length > 0) {
|
|
6
5
|
setResult({
|
|
@@ -16,7 +15,7 @@ const makeHandleResult = (options = {}) => ({ result, setResult }) => {
|
|
|
16
15
|
});
|
|
17
16
|
}
|
|
18
17
|
};
|
|
19
|
-
const useApolloServerErrors = (options = {}) => {
|
|
18
|
+
export const useApolloServerErrors = (options = {}) => {
|
|
20
19
|
return {
|
|
21
20
|
onExecute() {
|
|
22
21
|
const handleResult = makeHandleResult(options);
|
|
@@ -28,5 +27,3 @@ const useApolloServerErrors = (options = {}) => {
|
|
|
28
27
|
},
|
|
29
28
|
};
|
|
30
29
|
};
|
|
31
|
-
|
|
32
|
-
export { useApolloServerErrors };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/apollo-server-errors",
|
|
3
|
-
"version": "4.0.0-alpha-
|
|
3
|
+
"version": "4.0.0-alpha-5b6bfa8.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "3.0.0-alpha-
|
|
7
|
-
"graphql": "
|
|
6
|
+
"@envelop/core": "3.0.0-alpha-5b6bfa8.0",
|
|
7
|
+
"@graphql-tools/graphql": "0.1.0-alpha-33fb2950.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"apollo-server-errors": "3.3.
|
|
10
|
+
"apollo-server-errors": "^3.3.1"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -16,33 +16,42 @@
|
|
|
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
28
|
"require": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
29
|
+
"types": "./typings/index.d.ts",
|
|
30
|
+
"default": "./cjs/index.js"
|
|
30
31
|
},
|
|
31
32
|
"import": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
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"
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
"./*": {
|
|
37
42
|
"require": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
43
|
+
"types": "./typings/*.d.ts",
|
|
44
|
+
"default": "./cjs/*.js"
|
|
40
45
|
},
|
|
41
46
|
"import": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
47
|
+
"types": "./typings/*.d.ts",
|
|
48
|
+
"default": "./esm/*.js"
|
|
49
|
+
},
|
|
50
|
+
"default": {
|
|
51
|
+
"types": "./typings/*.d.ts",
|
|
52
|
+
"default": "./esm/*.js"
|
|
44
53
|
}
|
|
45
54
|
},
|
|
46
55
|
"./package.json": "./package.json"
|
|
47
56
|
}
|
|
48
|
-
}
|
|
57
|
+
}
|
|
File without changes
|