@graphql-tools/module-loader 7.1.14 → 7.2.0-alpha-b76ec274.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,30 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var n = {};
|
|
8
|
-
if (e) {
|
|
9
|
-
Object.keys(e).forEach(function (k) {
|
|
10
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return e[k];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
n['default'] = e;
|
|
20
|
-
return n;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
7
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ModuleLoader = void 0;
|
|
27
|
+
const graphql_1 = require("graphql");
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
const { access } = fs_1.promises;
|
|
28
30
|
const InvalidError = new Error(`Imported object was not a string, DocumentNode or GraphQLSchema`);
|
|
29
31
|
const createLoadError = (error) => new Error('Unable to load schema from module: ' + `${error.message || /* istanbul ignore next */ error}`);
|
|
30
32
|
// module:node/module#export
|
|
@@ -70,7 +72,7 @@ class ModuleLoader {
|
|
|
70
72
|
const { modulePath } = extractData(pointer);
|
|
71
73
|
try {
|
|
72
74
|
const moduleAbsolutePath = require.resolve(modulePath);
|
|
73
|
-
return
|
|
75
|
+
return (0, fs_1.existsSync)(moduleAbsolutePath);
|
|
74
76
|
}
|
|
75
77
|
catch (e) {
|
|
76
78
|
return false;
|
|
@@ -103,7 +105,7 @@ class ModuleLoader {
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
parse(pointer, importedModule) {
|
|
106
|
-
if (
|
|
108
|
+
if ((0, graphql_1.isSchema)(importedModule)) {
|
|
107
109
|
return {
|
|
108
110
|
schema: importedModule,
|
|
109
111
|
location: pointer,
|
|
@@ -132,7 +134,7 @@ class ModuleLoader {
|
|
|
132
134
|
// Sync and Async
|
|
133
135
|
async importModule(pointer) {
|
|
134
136
|
const { modulePath, exportName } = extractData(pointer);
|
|
135
|
-
const imported = await
|
|
137
|
+
const imported = await Promise.resolve().then(() => __importStar(require(modulePath)));
|
|
136
138
|
return this.extractFromModule(imported, modulePath, exportName || 'default');
|
|
137
139
|
}
|
|
138
140
|
importModuleSync(pointer) {
|
|
@@ -141,5 +143,4 @@ class ModuleLoader {
|
|
|
141
143
|
return this.extractFromModule(imported, modulePath, exportName);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
|
-
|
|
145
146
|
exports.ModuleLoader = ModuleLoader;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isSchema } from 'graphql';
|
|
2
|
-
import { existsSync, promises } from 'fs';
|
|
3
|
-
|
|
4
|
-
const { access } = promises;
|
|
2
|
+
import { existsSync, promises as fsPromises } from 'fs';
|
|
3
|
+
const { access } = fsPromises;
|
|
5
4
|
const InvalidError = new Error(`Imported object was not a string, DocumentNode or GraphQLSchema`);
|
|
6
5
|
const createLoadError = (error) => new Error('Unable to load schema from module: ' + `${error.message || /* istanbul ignore next */ error}`);
|
|
7
6
|
// module:node/module#export
|
|
@@ -24,7 +23,7 @@ function extractData(pointer) {
|
|
|
24
23
|
* })
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
class ModuleLoader {
|
|
26
|
+
export class ModuleLoader {
|
|
28
27
|
isExpressionValid(pointer) {
|
|
29
28
|
return typeof pointer === 'string' && pointer.toLowerCase().startsWith('module:');
|
|
30
29
|
}
|
|
@@ -118,5 +117,3 @@ class ModuleLoader {
|
|
|
118
117
|
return this.extractFromModule(imported, modulePath, exportName);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
|
-
|
|
122
|
-
export { ModuleLoader };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/module-loader",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0-alpha-b76ec274.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/utils": "8.
|
|
10
|
+
"@graphql-tools/utils": "8.8.0-alpha-b76ec274.0",
|
|
11
11
|
"tslib": "^2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -17,21 +17,42 @@
|
|
|
17
17
|
},
|
|
18
18
|
"author": "Dotan Simha <dotansimha@gmail.com>",
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"main": "index.js",
|
|
21
|
-
"module": "index.
|
|
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":
|
|
29
|
-
|
|
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":
|
|
33
|
-
|
|
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
|