@graphql-mesh/fusion-composition 0.5.0 → 0.5.1
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/federation-utils.js +9 -2
- package/esm/federation-utils.js +10 -3
- package/package.json +1 -1
package/cjs/federation-utils.js
CHANGED
|
@@ -32,11 +32,15 @@ function importFederationDirectives(subgraph, directives) {
|
|
|
32
32
|
let importStatement = linkDirectives.find(linkDirectiveArgs => linkDirectiveArgs.url?.startsWith('https://specs.apollo.dev/federation/'));
|
|
33
33
|
if (!importStatement) {
|
|
34
34
|
importStatement = {
|
|
35
|
-
url: 'https://specs.apollo.dev/federation/v2.
|
|
35
|
+
url: 'https://specs.apollo.dev/federation/v2.6',
|
|
36
36
|
import: [],
|
|
37
37
|
};
|
|
38
38
|
linkDirectives.push(importStatement);
|
|
39
39
|
}
|
|
40
|
+
// v2.0 is not supported so bump to v2.6
|
|
41
|
+
if (importStatement.url === 'https://specs.apollo.dev/federation/v2.0') {
|
|
42
|
+
importStatement.url = 'https://specs.apollo.dev/federation/v2.6';
|
|
43
|
+
}
|
|
40
44
|
importStatement.import = [...new Set([...(importStatement.import || []), ...directives])];
|
|
41
45
|
const extensions = (subgraph.extensions ||= {});
|
|
42
46
|
extensions.directives = schemaDirectives;
|
|
@@ -84,7 +88,10 @@ function detectAndAddMeshDirectives(subgraph) {
|
|
|
84
88
|
subgraph = (0, utils_1.mapSchema)(subgraph, {
|
|
85
89
|
[utils_1.MapperKind.DIRECTIVE]: directive => {
|
|
86
90
|
const directiveName = `@${directive.name}`;
|
|
87
|
-
if (!(0, graphql_1.isSpecifiedDirective)(directive) &&
|
|
91
|
+
if (!(0, graphql_1.isSpecifiedDirective)(directive) &&
|
|
92
|
+
!FEDERATION_V1_DIRECTIVES.includes(directiveName) &&
|
|
93
|
+
!directiveName.startsWith('@federation__') &&
|
|
94
|
+
directiveName !== '@link') {
|
|
88
95
|
meshDirectives.push(directiveName);
|
|
89
96
|
if (!directive.isRepeatable && directive.args.some(arg => arg.name === 'subgraph')) {
|
|
90
97
|
return new graphql_1.GraphQLDirective({
|
package/esm/federation-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLDirective, GraphQLSchema, isSpecifiedDirective } from 'graphql';
|
|
2
|
-
import { getDirectiveExtensions, MapperKind, mapSchema
|
|
2
|
+
import { getDirectiveExtensions, MapperKind, mapSchema } from '@graphql-tools/utils';
|
|
3
3
|
export function addFederation2DirectivesToSubgraph(subgraph) {
|
|
4
4
|
const schemaDirectives = getDirectiveExtensions(subgraph);
|
|
5
5
|
const linkDirectives = (schemaDirectives.link ||= []);
|
|
@@ -24,11 +24,15 @@ export function importFederationDirectives(subgraph, directives) {
|
|
|
24
24
|
let importStatement = linkDirectives.find(linkDirectiveArgs => linkDirectiveArgs.url?.startsWith('https://specs.apollo.dev/federation/'));
|
|
25
25
|
if (!importStatement) {
|
|
26
26
|
importStatement = {
|
|
27
|
-
url: 'https://specs.apollo.dev/federation/v2.
|
|
27
|
+
url: 'https://specs.apollo.dev/federation/v2.6',
|
|
28
28
|
import: [],
|
|
29
29
|
};
|
|
30
30
|
linkDirectives.push(importStatement);
|
|
31
31
|
}
|
|
32
|
+
// v2.0 is not supported so bump to v2.6
|
|
33
|
+
if (importStatement.url === 'https://specs.apollo.dev/federation/v2.0') {
|
|
34
|
+
importStatement.url = 'https://specs.apollo.dev/federation/v2.6';
|
|
35
|
+
}
|
|
32
36
|
importStatement.import = [...new Set([...(importStatement.import || []), ...directives])];
|
|
33
37
|
const extensions = (subgraph.extensions ||= {});
|
|
34
38
|
extensions.directives = schemaDirectives;
|
|
@@ -76,7 +80,10 @@ export function detectAndAddMeshDirectives(subgraph) {
|
|
|
76
80
|
subgraph = mapSchema(subgraph, {
|
|
77
81
|
[MapperKind.DIRECTIVE]: directive => {
|
|
78
82
|
const directiveName = `@${directive.name}`;
|
|
79
|
-
if (!isSpecifiedDirective(directive) &&
|
|
83
|
+
if (!isSpecifiedDirective(directive) &&
|
|
84
|
+
!FEDERATION_V1_DIRECTIVES.includes(directiveName) &&
|
|
85
|
+
!directiveName.startsWith('@federation__') &&
|
|
86
|
+
directiveName !== '@link') {
|
|
80
87
|
meshDirectives.push(directiveName);
|
|
81
88
|
if (!directive.isRepeatable && directive.args.some(arg => arg.name === 'subgraph')) {
|
|
82
89
|
return new GraphQLDirective({
|