@graphql-mesh/compose-cli 1.4.2-alpha-20250317135543-529da5294c3b7874d7bba222bb912ca47f46cdbc → 1.4.2-alpha-20250317152431-73bc66be90ac39b55ba63137168026616c969edf
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.
|
@@ -163,6 +163,7 @@ async function getComposedSchemaFromConfig(config, logger) {
|
|
|
163
163
|
assumeValidSDL: true,
|
|
164
164
|
});
|
|
165
165
|
if (additionalTypeDefs?.length) {
|
|
166
|
+
const originalComposedSchema = composedSchema;
|
|
166
167
|
composedSchema = (0, schema_1.mergeSchemas)({
|
|
167
168
|
schemas: [composedSchema],
|
|
168
169
|
typeDefs: additionalTypeDefs,
|
|
@@ -172,9 +173,8 @@ async function getComposedSchemaFromConfig(config, logger) {
|
|
|
172
173
|
// Fix extra additionalField annotations
|
|
173
174
|
if (composedSchema.getDirective('additionalField')) {
|
|
174
175
|
let composedSchemaAST = (0, utils_2.getDocumentNodeFromSchema)(composedSchema);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
[graphql_1.Kind.FIELD_DEFINITION](node) {
|
|
176
|
+
composedSchemaAST = (0, graphql_1.visit)(composedSchemaAST, {
|
|
177
|
+
[graphql_1.Kind.FIELD_DEFINITION](node, __key, __parent, __path, ancestors) {
|
|
178
178
|
const directiveNames = node.directives?.map(directive => directive.name.value);
|
|
179
179
|
if (directiveNames.includes('additionalField')) {
|
|
180
180
|
if (directiveNames.includes('join__field') || directiveNames.includes('source')) {
|
|
@@ -183,9 +183,14 @@ async function getComposedSchemaFromConfig(config, logger) {
|
|
|
183
183
|
directives: node.directives?.filter(directive => directive.name.value !== 'additionalField'),
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
const typeInAncestor = [...ancestors]
|
|
187
|
+
.reverse()
|
|
188
|
+
.find(ancestor => !Array.isArray(ancestor) &&
|
|
189
|
+
ancestor != null &&
|
|
190
|
+
typeof ancestor === 'object' &&
|
|
191
|
+
'kind' in ancestor);
|
|
192
|
+
if (typeInAncestor) {
|
|
193
|
+
const typeInOriginalSchema = originalComposedSchema.getType(typeInAncestor.name.value);
|
|
189
194
|
if (typeInOriginalSchema && 'getFields' in typeInOriginalSchema) {
|
|
190
195
|
const field = typeInOriginalSchema.getFields()[node.name.value];
|
|
191
196
|
if (field) {
|
|
@@ -198,7 +203,8 @@ async function getComposedSchemaFromConfig(config, logger) {
|
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
},
|
|
201
|
-
})
|
|
206
|
+
});
|
|
207
|
+
return (0, graphql_1.print)(composedSchemaAST);
|
|
202
208
|
}
|
|
203
209
|
}
|
|
204
210
|
/* TODO
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildSchema, getNamedType, isInterfaceType, isNamedType, Kind, parse, print,
|
|
1
|
+
import { buildSchema, getNamedType, isInterfaceType, isNamedType, Kind, parse, print, visit, } from 'graphql';
|
|
2
2
|
import { composeSubgraphs, futureAdditions, getAnnotatedSubgraphs, } from '@graphql-mesh/fusion-composition';
|
|
3
3
|
import { parseWithCache } from '@graphql-mesh/utils';
|
|
4
4
|
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
|
|
@@ -160,6 +160,7 @@ export async function getComposedSchemaFromConfig(config, logger) {
|
|
|
160
160
|
assumeValidSDL: true,
|
|
161
161
|
});
|
|
162
162
|
if (additionalTypeDefs?.length) {
|
|
163
|
+
const originalComposedSchema = composedSchema;
|
|
163
164
|
composedSchema = mergeSchemas({
|
|
164
165
|
schemas: [composedSchema],
|
|
165
166
|
typeDefs: additionalTypeDefs,
|
|
@@ -169,9 +170,8 @@ export async function getComposedSchemaFromConfig(config, logger) {
|
|
|
169
170
|
// Fix extra additionalField annotations
|
|
170
171
|
if (composedSchema.getDirective('additionalField')) {
|
|
171
172
|
let composedSchemaAST = getDocumentNodeFromSchema(composedSchema);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
[Kind.FIELD_DEFINITION](node) {
|
|
173
|
+
composedSchemaAST = visit(composedSchemaAST, {
|
|
174
|
+
[Kind.FIELD_DEFINITION](node, __key, __parent, __path, ancestors) {
|
|
175
175
|
const directiveNames = node.directives?.map(directive => directive.name.value);
|
|
176
176
|
if (directiveNames.includes('additionalField')) {
|
|
177
177
|
if (directiveNames.includes('join__field') || directiveNames.includes('source')) {
|
|
@@ -180,9 +180,14 @@ export async function getComposedSchemaFromConfig(config, logger) {
|
|
|
180
180
|
directives: node.directives?.filter(directive => directive.name.value !== 'additionalField'),
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
const typeInAncestor = [...ancestors]
|
|
184
|
+
.reverse()
|
|
185
|
+
.find(ancestor => !Array.isArray(ancestor) &&
|
|
186
|
+
ancestor != null &&
|
|
187
|
+
typeof ancestor === 'object' &&
|
|
188
|
+
'kind' in ancestor);
|
|
189
|
+
if (typeInAncestor) {
|
|
190
|
+
const typeInOriginalSchema = originalComposedSchema.getType(typeInAncestor.name.value);
|
|
186
191
|
if (typeInOriginalSchema && 'getFields' in typeInOriginalSchema) {
|
|
187
192
|
const field = typeInOriginalSchema.getFields()[node.name.value];
|
|
188
193
|
if (field) {
|
|
@@ -195,7 +200,8 @@ export async function getComposedSchemaFromConfig(config, logger) {
|
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
},
|
|
198
|
-
})
|
|
203
|
+
});
|
|
204
|
+
return print(composedSchemaAST);
|
|
199
205
|
}
|
|
200
206
|
}
|
|
201
207
|
/* TODO
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/compose-cli",
|
|
3
|
-
"version": "1.4.2-alpha-
|
|
3
|
+
"version": "1.4.2-alpha-20250317152431-73bc66be90ac39b55ba63137168026616c969edf",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|