@envelop/testing 4.4.0-alpha-aca44e1.0 → 4.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.
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const graphql = require('graphql');
6
- const core = require('@envelop/core');
7
- const utils = require('@graphql-tools/utils');
8
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectAsyncIteratorValues = exports.assertStreamExecutionValue = exports.assertSingleExecutionValue = exports.createTestkit = exports.createSpiedPlugin = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const core_1 = require("@envelop/core");
6
+ const utils_1 = require("@graphql-tools/utils");
9
7
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
10
8
  function createSpiedPlugin() {
11
9
  const afterResolver = jest.fn();
@@ -45,23 +43,24 @@ function createSpiedPlugin() {
45
43
  },
46
44
  };
47
45
  }
46
+ exports.createSpiedPlugin = createSpiedPlugin;
48
47
  function createTestkit(pluginsOrEnvelop, schema) {
49
48
  const toGraphQLErrorOrThrow = (thrownThing) => {
50
- if (thrownThing instanceof graphql.GraphQLError) {
49
+ if (thrownThing instanceof graphql_1.GraphQLError) {
51
50
  return thrownThing;
52
51
  }
53
52
  throw thrownThing;
54
53
  };
55
54
  const phasesReplacements = [];
56
55
  let getEnveloped = Array.isArray(pluginsOrEnvelop)
57
- ? core.envelop({
58
- plugins: [...(schema ? [core.useSchema(utils.mapSchema(schema))] : []), ...pluginsOrEnvelop],
56
+ ? (0, core_1.envelop)({
57
+ plugins: [...(schema ? [(0, core_1.useSchema)((0, utils_1.mapSchema)(schema))] : []), ...pluginsOrEnvelop],
59
58
  })
60
59
  : pluginsOrEnvelop;
61
60
  return {
62
61
  modifyPlugins(modifyPluginsFn) {
63
- getEnveloped = core.envelop({
64
- plugins: [...(schema ? [core.useSchema(utils.mapSchema(schema))] : []), ...modifyPluginsFn(getEnveloped._plugins)],
62
+ getEnveloped = (0, core_1.envelop)({
63
+ plugins: [...(schema ? [(0, core_1.useSchema)((0, utils_1.mapSchema)(schema))] : []), ...modifyPluginsFn(getEnveloped._plugins)],
65
64
  });
66
65
  },
67
66
  mockPhase(phaseReplacement) {
@@ -91,7 +90,7 @@ function createTestkit(pluginsOrEnvelop, schema) {
91
90
  }
92
91
  let document;
93
92
  try {
94
- document = utils.isDocumentNode(operation) ? operation : proxy.parse(operation);
93
+ document = (0, utils_1.isDocumentNode)(operation) ? operation : proxy.parse(operation);
95
94
  }
96
95
  catch (err) {
97
96
  return {
@@ -112,10 +111,10 @@ function createTestkit(pluginsOrEnvelop, schema) {
112
111
  errors: validationErrors,
113
112
  };
114
113
  }
115
- const mainOperation = graphql.getOperationAST(document);
114
+ const mainOperation = (0, graphql_1.getOperationAST)(document);
116
115
  if (mainOperation == null) {
117
116
  return {
118
- errors: [new graphql.GraphQLError('Could not identify main operation.')],
117
+ errors: [new graphql_1.GraphQLError('Could not identify main operation.')],
119
118
  };
120
119
  }
121
120
  const contextValue = await proxy.contextFactory({
@@ -124,12 +123,12 @@ function createTestkit(pluginsOrEnvelop, schema) {
124
123
  method: 'POST',
125
124
  query: '',
126
125
  body: {
127
- query: graphql.print(document),
126
+ query: (0, graphql_1.print)(document),
128
127
  variables: variableValues,
129
128
  },
130
129
  },
131
130
  document,
132
- operation: graphql.print(document),
131
+ operation: (0, graphql_1.print)(document),
133
132
  variables: variableValues,
134
133
  ...initialContext,
135
134
  });
@@ -152,16 +151,19 @@ function createTestkit(pluginsOrEnvelop, schema) {
152
151
  },
153
152
  };
154
153
  }
154
+ exports.createTestkit = createTestkit;
155
155
  function assertSingleExecutionValue(input) {
156
- if (core.isAsyncIterable(input)) {
156
+ if ((0, core_1.isAsyncIterable)(input)) {
157
157
  throw new Error('Received stream but expected single result');
158
158
  }
159
159
  }
160
+ exports.assertSingleExecutionValue = assertSingleExecutionValue;
160
161
  function assertStreamExecutionValue(input) {
161
- if (!core.isAsyncIterable(input)) {
162
+ if (!(0, core_1.isAsyncIterable)(input)) {
162
163
  throw new Error('Received single result but expected stream.');
163
164
  }
164
165
  }
166
+ exports.assertStreamExecutionValue = assertStreamExecutionValue;
165
167
  const collectAsyncIteratorValues = async (asyncIterable) => {
166
168
  const values = [];
167
169
  for await (const value of asyncIterable) {
@@ -169,9 +171,4 @@ const collectAsyncIteratorValues = async (asyncIterable) => {
169
171
  }
170
172
  return values;
171
173
  };
172
-
173
- exports.assertSingleExecutionValue = assertSingleExecutionValue;
174
- exports.assertStreamExecutionValue = assertStreamExecutionValue;
175
174
  exports.collectAsyncIteratorValues = collectAsyncIteratorValues;
176
- exports.createSpiedPlugin = createSpiedPlugin;
177
- exports.createTestkit = createTestkit;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,7 +1,9 @@
1
- import { getOperationAST, GraphQLError, print } from 'graphql';
2
- import { envelop, useSchema, isAsyncIterable } from '@envelop/core';
3
- import { mapSchema, isDocumentNode } from '@graphql-tools/utils';
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectAsyncIteratorValues = exports.assertStreamExecutionValue = exports.assertSingleExecutionValue = exports.createTestkit = exports.createSpiedPlugin = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const core_1 = require("@envelop/core");
6
+ const utils_1 = require("@graphql-tools/utils");
5
7
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6
8
  function createSpiedPlugin() {
7
9
  const afterResolver = jest.fn();
@@ -41,23 +43,24 @@ function createSpiedPlugin() {
41
43
  },
42
44
  };
43
45
  }
46
+ exports.createSpiedPlugin = createSpiedPlugin;
44
47
  function createTestkit(pluginsOrEnvelop, schema) {
45
48
  const toGraphQLErrorOrThrow = (thrownThing) => {
46
- if (thrownThing instanceof GraphQLError) {
49
+ if (thrownThing instanceof graphql_1.GraphQLError) {
47
50
  return thrownThing;
48
51
  }
49
52
  throw thrownThing;
50
53
  };
51
54
  const phasesReplacements = [];
52
55
  let getEnveloped = Array.isArray(pluginsOrEnvelop)
53
- ? envelop({
54
- plugins: [...(schema ? [useSchema(mapSchema(schema))] : []), ...pluginsOrEnvelop],
56
+ ? (0, core_1.envelop)({
57
+ plugins: [...(schema ? [(0, core_1.useSchema)((0, utils_1.mapSchema)(schema))] : []), ...pluginsOrEnvelop],
55
58
  })
56
59
  : pluginsOrEnvelop;
57
60
  return {
58
61
  modifyPlugins(modifyPluginsFn) {
59
- getEnveloped = envelop({
60
- plugins: [...(schema ? [useSchema(mapSchema(schema))] : []), ...modifyPluginsFn(getEnveloped._plugins)],
62
+ getEnveloped = (0, core_1.envelop)({
63
+ plugins: [...(schema ? [(0, core_1.useSchema)((0, utils_1.mapSchema)(schema))] : []), ...modifyPluginsFn(getEnveloped._plugins)],
61
64
  });
62
65
  },
63
66
  mockPhase(phaseReplacement) {
@@ -87,7 +90,7 @@ function createTestkit(pluginsOrEnvelop, schema) {
87
90
  }
88
91
  let document;
89
92
  try {
90
- document = isDocumentNode(operation) ? operation : proxy.parse(operation);
93
+ document = (0, utils_1.isDocumentNode)(operation) ? operation : proxy.parse(operation);
91
94
  }
92
95
  catch (err) {
93
96
  return {
@@ -108,10 +111,10 @@ function createTestkit(pluginsOrEnvelop, schema) {
108
111
  errors: validationErrors,
109
112
  };
110
113
  }
111
- const mainOperation = getOperationAST(document);
114
+ const mainOperation = (0, graphql_1.getOperationAST)(document);
112
115
  if (mainOperation == null) {
113
116
  return {
114
- errors: [new GraphQLError('Could not identify main operation.')],
117
+ errors: [new graphql_1.GraphQLError('Could not identify main operation.')],
115
118
  };
116
119
  }
117
120
  const contextValue = await proxy.contextFactory({
@@ -120,12 +123,12 @@ function createTestkit(pluginsOrEnvelop, schema) {
120
123
  method: 'POST',
121
124
  query: '',
122
125
  body: {
123
- query: print(document),
126
+ query: (0, graphql_1.print)(document),
124
127
  variables: variableValues,
125
128
  },
126
129
  },
127
130
  document,
128
- operation: print(document),
131
+ operation: (0, graphql_1.print)(document),
129
132
  variables: variableValues,
130
133
  ...initialContext,
131
134
  });
@@ -148,16 +151,19 @@ function createTestkit(pluginsOrEnvelop, schema) {
148
151
  },
149
152
  };
150
153
  }
154
+ exports.createTestkit = createTestkit;
151
155
  function assertSingleExecutionValue(input) {
152
- if (isAsyncIterable(input)) {
156
+ if ((0, core_1.isAsyncIterable)(input)) {
153
157
  throw new Error('Received stream but expected single result');
154
158
  }
155
159
  }
160
+ exports.assertSingleExecutionValue = assertSingleExecutionValue;
156
161
  function assertStreamExecutionValue(input) {
157
- if (!isAsyncIterable(input)) {
162
+ if (!(0, core_1.isAsyncIterable)(input)) {
158
163
  throw new Error('Received single result but expected stream.');
159
164
  }
160
165
  }
166
+ exports.assertStreamExecutionValue = assertStreamExecutionValue;
161
167
  const collectAsyncIteratorValues = async (asyncIterable) => {
162
168
  const values = [];
163
169
  for await (const value of asyncIterable) {
@@ -165,5 +171,4 @@ const collectAsyncIteratorValues = async (asyncIterable) => {
165
171
  }
166
172
  return values;
167
173
  };
168
-
169
- export { assertSingleExecutionValue, assertStreamExecutionValue, collectAsyncIteratorValues, createSpiedPlugin, createTestkit };
174
+ exports.collectAsyncIteratorValues = collectAsyncIteratorValues;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/testing",
3
- "version": "4.4.0-alpha-aca44e1.0",
3
+ "version": "4.4.0-alpha-e9434aa.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-aca44e1.0",
7
- "@envelop/types": "^2.2.0",
6
+ "@envelop/core": "2.4.0-alpha-e9434aa.0",
7
+ "@envelop/types": "2.3.0-alpha-e9434aa.0",
8
8
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
9
9
  },
10
10
  "dependencies": {
@@ -12,26 +12,47 @@
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/dotansimha/envelop.git",
15
+ "url": "https://github.com/n1ru4l/envelop.git",
16
16
  "directory": "packages/testing"
17
17
  },
18
18
  "author": "Dotan Simha <dotansimha@gmail.com>",
19
19
  "license": "MIT",
20
- "main": "index.js",
21
- "module": "index.mjs",
22
- "typings": "index.d.ts",
20
+ "main": "cjs/index.js",
21
+ "module": "esm/index.js",
22
+ "typings": "typings/index.d.ts",
23
23
  "typescript": {
24
- "definition": "index.d.ts"
24
+ "definition": "typings/index.d.ts"
25
25
  },
26
+ "type": "module",
26
27
  "exports": {
27
28
  ".": {
28
- "require": "./index.js",
29
- "import": "./index.mjs"
29
+ "require": {
30
+ "types": "./typings/index.d.ts",
31
+ "default": "./cjs/index.js"
32
+ },
33
+ "import": {
34
+ "types": "./typings/index.d.ts",
35
+ "default": "./esm/index.js"
36
+ },
37
+ "default": {
38
+ "types": "./typings/index.d.ts",
39
+ "default": "./esm/index.js"
40
+ }
30
41
  },
31
42
  "./*": {
32
- "require": "./*.js",
33
- "import": "./*.mjs"
43
+ "require": {
44
+ "types": "./typings/*.d.ts",
45
+ "default": "./cjs/*.js"
46
+ },
47
+ "import": {
48
+ "types": "./typings/*.d.ts",
49
+ "default": "./esm/*.js"
50
+ },
51
+ "default": {
52
+ "types": "./typings/*.d.ts",
53
+ "default": "./esm/*.js"
54
+ }
34
55
  },
35
56
  "./package.json": "./package.json"
36
57
  }
37
- }
58
+ }
File without changes