@graphql-mesh/merger-bare 0.15.5-alpha-4125801ca.0 → 0.15.5
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.d.ts +4 -10
- package/index.js +37 -2
- package/index.mjs +37 -2
- package/package.json +4 -3
package/index.d.ts
CHANGED
|
@@ -4,17 +4,10 @@ export default class BareMerger implements MeshMerger {
|
|
|
4
4
|
name: string;
|
|
5
5
|
private logger;
|
|
6
6
|
constructor(options: MeshMergerOptions);
|
|
7
|
-
|
|
7
|
+
handleSingleWrappedExtendedSource({ rawSources: [rawSource], typeDefs, resolvers }: MeshMergerContext): {
|
|
8
8
|
schema: GraphQLSchema;
|
|
9
|
-
name: string;
|
|
10
|
-
executor?: import("@graphql-tools/utils").Executor<Record<string, any>, Record<string, any>>;
|
|
11
|
-
transforms: import("@graphql-mesh/types").MeshTransform<any>[];
|
|
12
|
-
contextVariables: Record<string, string>;
|
|
13
|
-
handler: import("@graphql-mesh/types").MeshHandler;
|
|
14
|
-
batch: boolean;
|
|
15
|
-
merge?: Record<string, import("@graphql-tools/delegate").MergedTypeConfig<any, any, Record<string, any>>>;
|
|
16
9
|
};
|
|
17
|
-
|
|
10
|
+
handleSingleRegularSource({ rawSources: [rawSource], typeDefs, resolvers }: MeshMergerContext): {
|
|
18
11
|
schema: GraphQLSchema;
|
|
19
12
|
name: string;
|
|
20
13
|
executor?: import("@graphql-tools/utils").Executor<Record<string, any>, Record<string, any>>;
|
|
@@ -23,7 +16,8 @@ export default class BareMerger implements MeshMerger {
|
|
|
23
16
|
handler: import("@graphql-mesh/types").MeshHandler;
|
|
24
17
|
batch: boolean;
|
|
25
18
|
merge?: Record<string, import("@graphql-tools/delegate").MergedTypeConfig<any, any, Record<string, any>>>;
|
|
26
|
-
}
|
|
19
|
+
};
|
|
20
|
+
getUnifiedSchema({ rawSources, typeDefs, resolvers }: MeshMergerContext): Promise<{
|
|
27
21
|
schema: GraphQLSchema;
|
|
28
22
|
}>;
|
|
29
23
|
}
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const utils = require('@graphql-mesh/utils');
|
|
4
4
|
const schema = require('@graphql-tools/schema');
|
|
5
5
|
const utils$1 = require('@graphql-tools/utils');
|
|
6
|
+
const wrap = require('@graphql-tools/wrap');
|
|
6
7
|
const graphql = require('graphql');
|
|
7
8
|
|
|
8
9
|
class BareMerger {
|
|
@@ -10,7 +11,36 @@ class BareMerger {
|
|
|
10
11
|
this.name = 'bare';
|
|
11
12
|
this.logger = options.logger;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
handleSingleWrappedExtendedSource({ rawSources: [rawSource], typeDefs, resolvers }) {
|
|
15
|
+
let schema$1 = wrap.wrapSchema(rawSource);
|
|
16
|
+
if (typeDefs.length > 0 || utils$1.asArray(resolvers).length > 0) {
|
|
17
|
+
for (const typeDef of typeDefs) {
|
|
18
|
+
schema$1 = graphql.extendSchema(schema$1, typeDef);
|
|
19
|
+
}
|
|
20
|
+
for (const resolversObj of utils$1.asArray(resolvers)) {
|
|
21
|
+
schema.addResolversToSchema({
|
|
22
|
+
schema: schema$1,
|
|
23
|
+
resolvers: resolversObj,
|
|
24
|
+
updateResolversInPlace: true,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
this.logger.debug(`Attaching a dummy sourceMap to the final schema`);
|
|
29
|
+
schema$1.extensions = schema$1.extensions || {};
|
|
30
|
+
Object.defineProperty(schema$1.extensions, 'sourceMap', {
|
|
31
|
+
get: () => {
|
|
32
|
+
return {
|
|
33
|
+
get() {
|
|
34
|
+
return schema$1;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
schema: schema$1,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
handleSingleRegularSource({ rawSources: [rawSource], typeDefs, resolvers }) {
|
|
14
44
|
let schema$1 = rawSource.schema;
|
|
15
45
|
if (typeDefs.length > 0 || utils$1.asArray(resolvers).length > 0) {
|
|
16
46
|
for (const typeDef of typeDefs) {
|
|
@@ -44,8 +74,13 @@ class BareMerger {
|
|
|
44
74
|
};
|
|
45
75
|
}
|
|
46
76
|
async getUnifiedSchema({ rawSources, typeDefs, resolvers }) {
|
|
77
|
+
var _a;
|
|
47
78
|
if (rawSources.length === 1) {
|
|
48
|
-
|
|
79
|
+
if ((rawSources[0].executor || ((_a = rawSources[0].transforms) === null || _a === void 0 ? void 0 : _a.length)) &&
|
|
80
|
+
(typeDefs.length > 0 || utils$1.asArray(resolvers).length > 0)) {
|
|
81
|
+
return this.handleSingleWrappedExtendedSource({ rawSources, typeDefs, resolvers });
|
|
82
|
+
}
|
|
83
|
+
return this.handleSingleRegularSource({ rawSources, typeDefs, resolvers });
|
|
49
84
|
}
|
|
50
85
|
const sourceMap = new Map();
|
|
51
86
|
this.logger.debug(`Applying transforms for each source`);
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { applySchemaTransforms } from '@graphql-mesh/utils';
|
|
2
2
|
import { addResolversToSchema, mergeSchemas } from '@graphql-tools/schema';
|
|
3
3
|
import { asArray, getDocumentNodeFromSchema } from '@graphql-tools/utils';
|
|
4
|
+
import { wrapSchema } from '@graphql-tools/wrap';
|
|
4
5
|
import { extendSchema, buildASTSchema } from 'graphql';
|
|
5
6
|
|
|
6
7
|
class BareMerger {
|
|
@@ -8,7 +9,36 @@ class BareMerger {
|
|
|
8
9
|
this.name = 'bare';
|
|
9
10
|
this.logger = options.logger;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
handleSingleWrappedExtendedSource({ rawSources: [rawSource], typeDefs, resolvers }) {
|
|
13
|
+
let schema = wrapSchema(rawSource);
|
|
14
|
+
if (typeDefs.length > 0 || asArray(resolvers).length > 0) {
|
|
15
|
+
for (const typeDef of typeDefs) {
|
|
16
|
+
schema = extendSchema(schema, typeDef);
|
|
17
|
+
}
|
|
18
|
+
for (const resolversObj of asArray(resolvers)) {
|
|
19
|
+
addResolversToSchema({
|
|
20
|
+
schema,
|
|
21
|
+
resolvers: resolversObj,
|
|
22
|
+
updateResolversInPlace: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
this.logger.debug(`Attaching a dummy sourceMap to the final schema`);
|
|
27
|
+
schema.extensions = schema.extensions || {};
|
|
28
|
+
Object.defineProperty(schema.extensions, 'sourceMap', {
|
|
29
|
+
get: () => {
|
|
30
|
+
return {
|
|
31
|
+
get() {
|
|
32
|
+
return schema;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
schema,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
handleSingleRegularSource({ rawSources: [rawSource], typeDefs, resolvers }) {
|
|
12
42
|
let schema = rawSource.schema;
|
|
13
43
|
if (typeDefs.length > 0 || asArray(resolvers).length > 0) {
|
|
14
44
|
for (const typeDef of typeDefs) {
|
|
@@ -42,8 +72,13 @@ class BareMerger {
|
|
|
42
72
|
};
|
|
43
73
|
}
|
|
44
74
|
async getUnifiedSchema({ rawSources, typeDefs, resolvers }) {
|
|
75
|
+
var _a;
|
|
45
76
|
if (rawSources.length === 1) {
|
|
46
|
-
|
|
77
|
+
if ((rawSources[0].executor || ((_a = rawSources[0].transforms) === null || _a === void 0 ? void 0 : _a.length)) &&
|
|
78
|
+
(typeDefs.length > 0 || asArray(resolvers).length > 0)) {
|
|
79
|
+
return this.handleSingleWrappedExtendedSource({ rawSources, typeDefs, resolvers });
|
|
80
|
+
}
|
|
81
|
+
return this.handleSingleRegularSource({ rawSources, typeDefs, resolvers });
|
|
47
82
|
}
|
|
48
83
|
const sourceMap = new Map();
|
|
49
84
|
this.logger.debug(`Applying transforms for each source`);
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/merger-bare",
|
|
3
|
-
"version": "0.15.5
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-mesh/types": "0.78.
|
|
10
|
-
"@graphql-mesh/utils": "0.37.
|
|
9
|
+
"@graphql-mesh/types": "0.78.4",
|
|
10
|
+
"@graphql-mesh/utils": "0.37.5",
|
|
11
11
|
"@graphql-tools/schema": "8.5.0",
|
|
12
12
|
"@graphql-tools/utils": "8.8.0",
|
|
13
|
+
"@graphql-tools/wrap": "8.5.0",
|
|
13
14
|
"tslib": "^2.4.0"
|
|
14
15
|
},
|
|
15
16
|
"repository": {
|