@envelop/apollo-server-errors 3.4.0-alpha-aca44e1.0 → 3.4.0-alpha-385b86b.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.
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const core = require('@envelop/core');
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: apolloServerErrors.formatApolloErrors(result.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 core.handleStreamOrSingleExecutionResult(payload, handleResult);
27
+ return (0, core_1.handleStreamOrSingleExecutionResult)(payload, handleResult);
30
28
  },
31
29
  };
32
30
  },
33
31
  };
34
32
  };
35
-
36
33
  exports.useApolloServerErrors = useApolloServerErrors;
@@ -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,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/apollo-server-errors",
3
- "version": "3.4.0-alpha-aca44e1.0",
3
+ "version": "3.4.0-alpha-385b86b.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-aca44e1.0",
6
+ "@envelop/core": "2.4.0-alpha-385b86b.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/dotansimha/envelop.git",
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.mjs",
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": "./index.js",
28
- "import": "./index.mjs"
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": "./*.js",
32
- "import": "./*.mjs"
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
- ```