@graphql-mesh/transform-extend 1.0.0-alpha-3fc47d119.0 → 1.0.0-alpha-20230420181317-a95037648
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} +20 -20
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +7 -8
- package/package.json +29 -22
- package/typings/index.d.cts +9 -0
- package/{index.d.ts → typings/index.d.ts} +1 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
4
|
+
const code_file_loader_1 = require("@graphql-tools/code-file-loader");
|
|
5
|
+
const graphql_file_loader_1 = require("@graphql-tools/graphql-file-loader");
|
|
6
|
+
const load_1 = require("@graphql-tools/load");
|
|
7
|
+
const schema_1 = require("@graphql-tools/schema");
|
|
8
|
+
const utils_1 = require("@graphql-tools/utils");
|
|
10
9
|
function loadFromModuleExportExpressionSync({ expression, defaultExportName, cwd, }) {
|
|
11
10
|
if (typeof expression !== 'string') {
|
|
12
11
|
return expression;
|
|
@@ -20,8 +19,10 @@ function tryRequire(modulePath, cwd) {
|
|
|
20
19
|
return require(modulePath);
|
|
21
20
|
}
|
|
22
21
|
catch (_a) {
|
|
23
|
-
if (!
|
|
24
|
-
const absoluteModulePath =
|
|
22
|
+
if (!cross_helpers_1.path.isAbsolute(modulePath)) {
|
|
23
|
+
const absoluteModulePath = cross_helpers_1.path.isAbsolute(modulePath)
|
|
24
|
+
? modulePath
|
|
25
|
+
: cross_helpers_1.path.join(cwd, modulePath);
|
|
25
26
|
return require(absoluteModulePath);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -32,13 +33,13 @@ class ExtendTransform {
|
|
|
32
33
|
this.config = config;
|
|
33
34
|
this.baseDir = baseDir;
|
|
34
35
|
}
|
|
35
|
-
transformSchema(schema
|
|
36
|
-
const sources =
|
|
37
|
-
cwd:
|
|
38
|
-
loaders: [new
|
|
36
|
+
transformSchema(schema) {
|
|
37
|
+
const sources = (0, load_1.loadTypedefsSync)(this.config.typeDefs, {
|
|
38
|
+
cwd: cross_helpers_1.path.isAbsolute(this.config.typeDefs) ? null : this.baseDir,
|
|
39
|
+
loaders: [new code_file_loader_1.CodeFileLoader(), new graphql_file_loader_1.GraphQLFileLoader()],
|
|
39
40
|
});
|
|
40
41
|
const typeDefs = sources.map(source => source.document);
|
|
41
|
-
const resolvers =
|
|
42
|
+
const resolvers = (0, utils_1.asArray)(this.config.resolvers).map(resolverDef => {
|
|
42
43
|
if (typeof resolverDef === 'string') {
|
|
43
44
|
return loadFromModuleExportExpressionSync({
|
|
44
45
|
expression: resolverDef,
|
|
@@ -50,12 +51,11 @@ class ExtendTransform {
|
|
|
50
51
|
return resolverDef;
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
|
-
return
|
|
54
|
-
schemas: [schema
|
|
54
|
+
return (0, schema_1.mergeSchemas)({
|
|
55
|
+
schemas: [schema],
|
|
55
56
|
typeDefs,
|
|
56
57
|
resolvers,
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
module.exports = ExtendTransform;
|
|
61
|
+
exports.default = ExtendTransform;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { path } from '@graphql-mesh/cross-helpers';
|
|
1
|
+
import { path as pathModule } from '@graphql-mesh/cross-helpers';
|
|
2
2
|
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
|
|
3
3
|
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
|
|
4
4
|
import { loadTypedefsSync } from '@graphql-tools/load';
|
|
5
5
|
import { mergeSchemas } from '@graphql-tools/schema';
|
|
6
6
|
import { asArray } from '@graphql-tools/utils';
|
|
7
|
-
|
|
8
7
|
function loadFromModuleExportExpressionSync({ expression, defaultExportName, cwd, }) {
|
|
9
8
|
if (typeof expression !== 'string') {
|
|
10
9
|
return expression;
|
|
@@ -18,13 +17,15 @@ function tryRequire(modulePath, cwd) {
|
|
|
18
17
|
return require(modulePath);
|
|
19
18
|
}
|
|
20
19
|
catch (_a) {
|
|
21
|
-
if (!
|
|
22
|
-
const absoluteModulePath =
|
|
20
|
+
if (!pathModule.isAbsolute(modulePath)) {
|
|
21
|
+
const absoluteModulePath = pathModule.isAbsolute(modulePath)
|
|
22
|
+
? modulePath
|
|
23
|
+
: pathModule.join(cwd, modulePath);
|
|
23
24
|
return require(absoluteModulePath);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
class ExtendTransform {
|
|
28
|
+
export default class ExtendTransform {
|
|
28
29
|
constructor({ baseDir, config }) {
|
|
29
30
|
this.noWrap = true;
|
|
30
31
|
this.config = config;
|
|
@@ -32,7 +33,7 @@ class ExtendTransform {
|
|
|
32
33
|
}
|
|
33
34
|
transformSchema(schema) {
|
|
34
35
|
const sources = loadTypedefsSync(this.config.typeDefs, {
|
|
35
|
-
cwd:
|
|
36
|
+
cwd: pathModule.isAbsolute(this.config.typeDefs) ? null : this.baseDir,
|
|
36
37
|
loaders: [new CodeFileLoader(), new GraphQLFileLoader()],
|
|
37
38
|
});
|
|
38
39
|
const typeDefs = sources.map(source => source.document);
|
|
@@ -55,5 +56,3 @@ class ExtendTransform {
|
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
export default ExtendTransform;
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/transform-extend",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230420181317-a95037648",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/
|
|
7
|
-
"@graphql-mesh/
|
|
8
|
-
"graphql": "
|
|
6
|
+
"@graphql-mesh/cross-helpers": "^0.3.4",
|
|
7
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230420181317-a95037648",
|
|
8
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230420181317-a95037648",
|
|
9
|
+
"@graphql-tools/utils": "^9.2.1",
|
|
10
|
+
"graphql": "*",
|
|
11
|
+
"tslib": "^2.4.0"
|
|
9
12
|
},
|
|
10
13
|
"dependencies": {
|
|
11
|
-
"@graphql-
|
|
12
|
-
"@graphql-tools/
|
|
13
|
-
"@graphql-tools/
|
|
14
|
-
"@graphql-tools/
|
|
15
|
-
"@graphql-tools/schema": "8.5.0",
|
|
16
|
-
"@graphql-tools/utils": "8.8.0",
|
|
17
|
-
"tslib": "^2.4.0"
|
|
14
|
+
"@graphql-tools/code-file-loader": "7.3.22",
|
|
15
|
+
"@graphql-tools/graphql-file-loader": "7.5.17",
|
|
16
|
+
"@graphql-tools/load": "7.8.14",
|
|
17
|
+
"@graphql-tools/schema": "9.0.18"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -22,21 +22,28 @@
|
|
|
22
22
|
"directory": "packages/transforms/extend"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
|
-
"main": "index.js",
|
|
26
|
-
"module": "index.
|
|
27
|
-
"typings": "index.d.ts",
|
|
25
|
+
"main": "cjs/index.js",
|
|
26
|
+
"module": "esm/index.js",
|
|
27
|
+
"typings": "typings/index.d.ts",
|
|
28
28
|
"typescript": {
|
|
29
|
-
"definition": "index.d.ts"
|
|
29
|
+
"definition": "typings/index.d.ts"
|
|
30
30
|
},
|
|
31
|
+
"type": "module",
|
|
31
32
|
"exports": {
|
|
32
33
|
".": {
|
|
33
|
-
"require":
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./typings/index.d.cts",
|
|
36
|
+
"default": "./cjs/index.js"
|
|
37
|
+
},
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./typings/index.d.ts",
|
|
40
|
+
"default": "./esm/index.js"
|
|
41
|
+
},
|
|
42
|
+
"default": {
|
|
43
|
+
"types": "./typings/index.d.ts",
|
|
44
|
+
"default": "./esm/index.js"
|
|
45
|
+
}
|
|
39
46
|
},
|
|
40
47
|
"./package.json": "./package.json"
|
|
41
48
|
}
|
|
42
|
-
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { MeshTransform, MeshTransformOptions, YamlConfig } from '@graphql-mesh/types';
|
|
3
|
+
export default class ExtendTransform implements MeshTransform {
|
|
4
|
+
noWrap: boolean;
|
|
5
|
+
private config;
|
|
6
|
+
private baseDir;
|
|
7
|
+
constructor({ baseDir, config }: MeshTransformOptions<YamlConfig.ExtendTransform>);
|
|
8
|
+
transformSchema(schema: GraphQLSchema): GraphQLSchema;
|
|
9
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MeshTransform, MeshTransformOptions, YamlConfig } from '@graphql-mesh/types';
|
|
2
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { MeshTransform, MeshTransformOptions, YamlConfig } from '@graphql-mesh/types';
|
|
3
3
|
export default class ExtendTransform implements MeshTransform {
|
|
4
4
|
noWrap: boolean;
|
|
5
5
|
private config;
|