@graphql-mesh/fusion-composition 0.7.9 → 0.7.10
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/compose.js +3 -0
- package/cjs/transforms/federation.js +17 -1
- package/esm/compose.js +3 -0
- package/esm/transforms/federation.js +17 -1
- package/package.json +1 -1
package/cjs/compose.js
CHANGED
|
@@ -252,6 +252,9 @@ function getAnnotatedSubgraphs(subgraphs, options = {}) {
|
|
|
252
252
|
if (directive.name === 'transport' && removeTransportDirective) {
|
|
253
253
|
return null;
|
|
254
254
|
}
|
|
255
|
+
if (!sourceDirectiveUsed && directive.name === 'source') {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
255
258
|
},
|
|
256
259
|
});
|
|
257
260
|
let transformedSubgraph = annotatedSubgraph;
|
|
@@ -98,8 +98,22 @@ function createFederationTransform(config) {
|
|
|
98
98
|
}
|
|
99
99
|
const mergeDirectiveConfigForOperation = mergeDirectiveConfigMap.get(operation);
|
|
100
100
|
const mergeDirectiveConfig = mergeDirectiveConfigForOperation?.get(fieldName);
|
|
101
|
+
const fieldDirectives = (0, utils_1.getDirectiveExtensions)(fieldConfig) || {};
|
|
102
|
+
const fieldTransformConfig = configurationByField.get(typeName)?.get(fieldName);
|
|
103
|
+
if (fieldTransformConfig) {
|
|
104
|
+
for (const directiveName in fieldTransformConfig) {
|
|
105
|
+
const directiveConfigs = (0, utils_1.asArray)(fieldTransformConfig[directiveName]);
|
|
106
|
+
const specificDirectiveExtensions = (fieldDirectives[directiveName] ||= []);
|
|
107
|
+
for (let directiveConfig of directiveConfigs) {
|
|
108
|
+
if (typeof directiveConfig === 'boolean') {
|
|
109
|
+
directiveConfig = {};
|
|
110
|
+
}
|
|
111
|
+
specificDirectiveExtensions.push(directiveConfig);
|
|
112
|
+
usedFederationDirectives.add(`@${directiveName}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
101
116
|
if (mergeDirectiveConfig) {
|
|
102
|
-
const fieldDirectives = (0, utils_1.getDirectiveExtensions)(fieldConfig) || {};
|
|
103
117
|
const mergeDirectiveExtensions = (fieldDirectives.merge ||= []);
|
|
104
118
|
let argsExpr = mergeDirectiveConfig.argsExpr;
|
|
105
119
|
if (!argsExpr && fieldConfig.args && !mergeDirectiveConfig.keyArg) {
|
|
@@ -129,6 +143,8 @@ function createFederationTransform(config) {
|
|
|
129
143
|
argsExpr,
|
|
130
144
|
});
|
|
131
145
|
mergeDirectiveUsed = true;
|
|
146
|
+
}
|
|
147
|
+
if (fieldTransformConfig || mergeDirectiveConfig) {
|
|
132
148
|
return {
|
|
133
149
|
...fieldConfig,
|
|
134
150
|
astNode: undefined,
|
package/esm/compose.js
CHANGED
|
@@ -245,6 +245,9 @@ export function getAnnotatedSubgraphs(subgraphs, options = {}) {
|
|
|
245
245
|
if (directive.name === 'transport' && removeTransportDirective) {
|
|
246
246
|
return null;
|
|
247
247
|
}
|
|
248
|
+
if (!sourceDirectiveUsed && directive.name === 'source') {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
248
251
|
},
|
|
249
252
|
});
|
|
250
253
|
let transformedSubgraph = annotatedSubgraph;
|
|
@@ -95,8 +95,22 @@ export function createFederationTransform(config) {
|
|
|
95
95
|
}
|
|
96
96
|
const mergeDirectiveConfigForOperation = mergeDirectiveConfigMap.get(operation);
|
|
97
97
|
const mergeDirectiveConfig = mergeDirectiveConfigForOperation?.get(fieldName);
|
|
98
|
+
const fieldDirectives = getDirectiveExtensions(fieldConfig) || {};
|
|
99
|
+
const fieldTransformConfig = configurationByField.get(typeName)?.get(fieldName);
|
|
100
|
+
if (fieldTransformConfig) {
|
|
101
|
+
for (const directiveName in fieldTransformConfig) {
|
|
102
|
+
const directiveConfigs = asArray(fieldTransformConfig[directiveName]);
|
|
103
|
+
const specificDirectiveExtensions = (fieldDirectives[directiveName] ||= []);
|
|
104
|
+
for (let directiveConfig of directiveConfigs) {
|
|
105
|
+
if (typeof directiveConfig === 'boolean') {
|
|
106
|
+
directiveConfig = {};
|
|
107
|
+
}
|
|
108
|
+
specificDirectiveExtensions.push(directiveConfig);
|
|
109
|
+
usedFederationDirectives.add(`@${directiveName}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
98
113
|
if (mergeDirectiveConfig) {
|
|
99
|
-
const fieldDirectives = getDirectiveExtensions(fieldConfig) || {};
|
|
100
114
|
const mergeDirectiveExtensions = (fieldDirectives.merge ||= []);
|
|
101
115
|
let argsExpr = mergeDirectiveConfig.argsExpr;
|
|
102
116
|
if (!argsExpr && fieldConfig.args && !mergeDirectiveConfig.keyArg) {
|
|
@@ -126,6 +140,8 @@ export function createFederationTransform(config) {
|
|
|
126
140
|
argsExpr,
|
|
127
141
|
});
|
|
128
142
|
mergeDirectiveUsed = true;
|
|
143
|
+
}
|
|
144
|
+
if (fieldTransformConfig || mergeDirectiveConfig) {
|
|
129
145
|
return {
|
|
130
146
|
...fieldConfig,
|
|
131
147
|
astNode: undefined,
|