@theguild/federation-composition 0.8.1 → 0.8.2-alpha-20240222132910-b4a7fdf
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/cjs/graphql/contains-supergraph-spec.js +14 -0
- package/cjs/graphql/transform-supergraph-to-public-schema.js +15 -7
- package/cjs/index.js +3 -1
- package/esm/graphql/contains-supergraph-spec.js +10 -0
- package/esm/graphql/transform-supergraph-to-public-schema.js +11 -3
- package/esm/index.js +1 -0
- package/package.json +1 -1
- package/typings/graphql/contains-supergraph-spec.d.cts +2 -0
- package/typings/graphql/contains-supergraph-spec.d.ts +2 -0
- package/typings/graphql/transform-supergraph-to-public-schema.d.cts +3 -0
- package/typings/graphql/transform-supergraph-to-public-schema.d.ts +3 -0
- package/typings/index.d.cts +1 -0
- package/typings/index.d.ts +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containsSupergraphSpec = void 0;
|
|
4
|
+
const transform_supergraph_to_public_schema_js_1 = require("./transform-supergraph-to-public-schema.js");
|
|
5
|
+
const supergraphSpecDetectionRegex = new RegExp(Array.from(transform_supergraph_to_public_schema_js_1.federationScalars)
|
|
6
|
+
.concat(Array.from(transform_supergraph_to_public_schema_js_1.federationEnums))
|
|
7
|
+
.map(name => [`\\[${name}`, `\\s${name}`])
|
|
8
|
+
.flat(2)
|
|
9
|
+
.concat(Array.from(transform_supergraph_to_public_schema_js_1.federationDirectives).map(name => `@${name}`))
|
|
10
|
+
.join('|'));
|
|
11
|
+
function containsSupergraphSpec(sdl) {
|
|
12
|
+
return supergraphSpecDetectionRegex.test(sdl);
|
|
13
|
+
}
|
|
14
|
+
exports.containsSupergraphSpec = containsSupergraphSpec;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformSupergraphToPublicSchema = void 0;
|
|
3
|
+
exports.transformSupergraphToPublicSchema = exports.federationDirectives = exports.federationEnums = exports.federationScalars = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
exports.federationScalars = new Set([
|
|
6
|
+
'_FieldSet',
|
|
7
|
+
'link__Import',
|
|
8
|
+
'join__FieldSet',
|
|
9
|
+
'join__DirectiveArguments',
|
|
10
|
+
'policy__Policy',
|
|
11
|
+
'requiresScopes__Scope',
|
|
12
|
+
]);
|
|
13
|
+
exports.federationEnums = new Set(['core__Purpose', 'join__Graph', 'link__Purpose']);
|
|
14
|
+
exports.federationDirectives = new Set([
|
|
8
15
|
'link',
|
|
9
16
|
'tag',
|
|
10
17
|
'join__graph',
|
|
11
18
|
'join__type',
|
|
12
19
|
'join__implements',
|
|
13
20
|
'join__unionMember',
|
|
21
|
+
'join__directive',
|
|
14
22
|
'join__enumValue',
|
|
15
23
|
'join__field',
|
|
16
24
|
'inaccessible',
|
|
@@ -58,7 +66,7 @@ function transformSupergraphToPublicSchema(documentNode) {
|
|
|
58
66
|
const additionalFederationDirectives = getAdditionalDirectivesToStrip(documentNode);
|
|
59
67
|
const inaccessibleDirectiveName = getInaccessibleDirectiveName(documentNode);
|
|
60
68
|
function removeFederationOrSpecifiedDirectives(node) {
|
|
61
|
-
if (federationDirectives.has(node.name.value) ||
|
|
69
|
+
if (exports.federationDirectives.has(node.name.value) ||
|
|
62
70
|
additionalFederationDirectives?.has(node.name.value) ||
|
|
63
71
|
(node.kind === graphql_1.Kind.DIRECTIVE_DEFINITION && specifiedDirectives.has(node.name.value))) {
|
|
64
72
|
return null;
|
|
@@ -78,12 +86,12 @@ function transformSupergraphToPublicSchema(documentNode) {
|
|
|
78
86
|
[graphql_1.Kind.SCHEMA_EXTENSION]: () => null,
|
|
79
87
|
[graphql_1.Kind.SCHEMA_DEFINITION]: () => null,
|
|
80
88
|
[graphql_1.Kind.SCALAR_TYPE_DEFINITION](node) {
|
|
81
|
-
if (federationScalars.has(node.name.value) || hasInaccessibleDirective(node)) {
|
|
89
|
+
if (exports.federationScalars.has(node.name.value) || hasInaccessibleDirective(node)) {
|
|
82
90
|
return null;
|
|
83
91
|
}
|
|
84
92
|
},
|
|
85
93
|
[graphql_1.Kind.ENUM_TYPE_DEFINITION](node) {
|
|
86
|
-
if (federationEnums.has(node.name.value) || hasInaccessibleDirective(node)) {
|
|
94
|
+
if (exports.federationEnums.has(node.name.value) || hasInaccessibleDirective(node)) {
|
|
87
95
|
return null;
|
|
88
96
|
}
|
|
89
97
|
},
|
package/cjs/index.js
CHANGED
|
@@ -14,11 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.sortSDL = exports.transformSupergraphToPublicSchema = void 0;
|
|
17
|
+
exports.sortSDL = exports.containsSupergraphSpec = exports.transformSupergraphToPublicSchema = void 0;
|
|
18
18
|
__exportStar(require("./compose.js"), exports);
|
|
19
19
|
__exportStar(require("./types.js"), exports);
|
|
20
20
|
__exportStar(require("./validate.js"), exports);
|
|
21
21
|
var transform_supergraph_to_public_schema_js_1 = require("./graphql/transform-supergraph-to-public-schema.js");
|
|
22
22
|
Object.defineProperty(exports, "transformSupergraphToPublicSchema", { enumerable: true, get: function () { return transform_supergraph_to_public_schema_js_1.transformSupergraphToPublicSchema; } });
|
|
23
|
+
var contains_supergraph_spec_js_1 = require("./graphql/contains-supergraph-spec.js");
|
|
24
|
+
Object.defineProperty(exports, "containsSupergraphSpec", { enumerable: true, get: function () { return contains_supergraph_spec_js_1.containsSupergraphSpec; } });
|
|
23
25
|
var sort_sdl_js_1 = require("./graphql/sort-sdl.js");
|
|
24
26
|
Object.defineProperty(exports, "sortSDL", { enumerable: true, get: function () { return sort_sdl_js_1.sortSDL; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { federationDirectives, federationEnums, federationScalars } from "./transform-supergraph-to-public-schema.js";
|
|
2
|
+
const supergraphSpecDetectionRegex = new RegExp(Array.from(federationScalars)
|
|
3
|
+
.concat(Array.from(federationEnums))
|
|
4
|
+
.map(name => [`\\[${name}`, `\\s${name}`])
|
|
5
|
+
.flat(2)
|
|
6
|
+
.concat(Array.from(federationDirectives).map(name => `@${name}`))
|
|
7
|
+
.join('|'));
|
|
8
|
+
export function containsSupergraphSpec(sdl) {
|
|
9
|
+
return supergraphSpecDetectionRegex.test(sdl);
|
|
10
|
+
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { Kind, specifiedDirectives as specifiedDirectivesArray, visit, } from 'graphql';
|
|
2
|
-
const federationScalars = new Set([
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export const federationScalars = new Set([
|
|
3
|
+
'_FieldSet',
|
|
4
|
+
'link__Import',
|
|
5
|
+
'join__FieldSet',
|
|
6
|
+
'join__DirectiveArguments',
|
|
7
|
+
'policy__Policy',
|
|
8
|
+
'requiresScopes__Scope',
|
|
9
|
+
]);
|
|
10
|
+
export const federationEnums = new Set(['core__Purpose', 'join__Graph', 'link__Purpose']);
|
|
11
|
+
export const federationDirectives = new Set([
|
|
5
12
|
'link',
|
|
6
13
|
'tag',
|
|
7
14
|
'join__graph',
|
|
8
15
|
'join__type',
|
|
9
16
|
'join__implements',
|
|
10
17
|
'join__unionMember',
|
|
18
|
+
'join__directive',
|
|
11
19
|
'join__enumValue',
|
|
12
20
|
'join__field',
|
|
13
21
|
'inaccessible',
|
package/esm/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export * from './compose.js';
|
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './validate.js';
|
|
4
4
|
export { transformSupergraphToPublicSchema } from './graphql/transform-supergraph-to-public-schema.js';
|
|
5
|
+
export { containsSupergraphSpec } from './graphql/contains-supergraph-spec.js';
|
|
5
6
|
export { sortSDL } from './graphql/sort-sdl.js';
|
package/package.json
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { type DocumentNode } from 'graphql';
|
|
2
|
+
export declare const federationScalars: Set<string>;
|
|
3
|
+
export declare const federationEnums: Set<string>;
|
|
4
|
+
export declare const federationDirectives: Set<string>;
|
|
2
5
|
export declare function transformSupergraphToPublicSchema(documentNode: DocumentNode): DocumentNode;
|
|
3
6
|
//# sourceMappingURL=transform-supergraph-to-public-schema.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { type DocumentNode } from 'graphql';
|
|
2
|
+
export declare const federationScalars: Set<string>;
|
|
3
|
+
export declare const federationEnums: Set<string>;
|
|
4
|
+
export declare const federationDirectives: Set<string>;
|
|
2
5
|
export declare function transformSupergraphToPublicSchema(documentNode: DocumentNode): DocumentNode;
|
|
3
6
|
//# sourceMappingURL=transform-supergraph-to-public-schema.d.ts.map
|
package/typings/index.d.cts
CHANGED
|
@@ -2,5 +2,6 @@ export * from './compose.cjs';
|
|
|
2
2
|
export * from './types.cjs';
|
|
3
3
|
export * from './validate.cjs';
|
|
4
4
|
export { transformSupergraphToPublicSchema } from './graphql/transform-supergraph-to-public-schema.cjs';
|
|
5
|
+
export { containsSupergraphSpec } from './graphql/contains-supergraph-spec.cjs';
|
|
5
6
|
export { sortSDL } from './graphql/sort-sdl.cjs';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/typings/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export * from './compose.js';
|
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './validate.js';
|
|
4
4
|
export { transformSupergraphToPublicSchema } from './graphql/transform-supergraph-to-public-schema.js';
|
|
5
|
+
export { containsSupergraphSpec } from './graphql/contains-supergraph-spec.js';
|
|
5
6
|
export { sortSDL } from './graphql/sort-sdl.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|