@graphql-mesh/compose-cli 1.2.10 → 1.3.0-alpha-20241202162739-65f4d2fb102c00ad9ed40a4a2fc62ecc00e0c69c
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.
|
@@ -113,8 +113,51 @@ async function getComposedSchemaFromConfig(config, logger) {
|
|
|
113
113
|
logger.error(`Unknown error: Supergraph is empty`);
|
|
114
114
|
process.exit(1);
|
|
115
115
|
}
|
|
116
|
+
let composedSchema;
|
|
117
|
+
if (fusion_composition_1.futureAdditions.length) {
|
|
118
|
+
let futureAddition;
|
|
119
|
+
while ((futureAddition = fusion_composition_1.futureAdditions.pop())) {
|
|
120
|
+
additionalTypeDefs ||= [];
|
|
121
|
+
composedSchema ||= (0, graphql_1.buildSchema)(result.supergraphSdl, {
|
|
122
|
+
noLocation: true,
|
|
123
|
+
assumeValid: true,
|
|
124
|
+
assumeValidSDL: true,
|
|
125
|
+
});
|
|
126
|
+
const sourceType = composedSchema.getType(futureAddition.sourceTypeName);
|
|
127
|
+
if (!sourceType) {
|
|
128
|
+
logger.error(`Target type ${futureAddition.sourceTypeName} not found`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
const sourceField = sourceType.getFields()[futureAddition.sourceFieldName];
|
|
132
|
+
if (!sourceField) {
|
|
133
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} not found`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
const sourceReturnType = (0, graphql_1.getNamedType)(sourceField.type);
|
|
137
|
+
if (!(0, graphql_1.isNamedType)(sourceReturnType)) {
|
|
138
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} has no return type`);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
const interfaceOrType = (0, graphql_1.isInterfaceType)(composedSchema.getType(futureAddition.targetTypeName))
|
|
142
|
+
? 'interface'
|
|
143
|
+
: 'type';
|
|
144
|
+
additionalTypeDefs.push((0, graphql_1.parse)(/* GraphQL */ `
|
|
145
|
+
extend ${interfaceOrType} ${futureAddition.targetTypeName} {
|
|
146
|
+
${futureAddition.targetFieldName}: ${sourceReturnType}
|
|
147
|
+
@additionalField
|
|
148
|
+
@resolveTo(
|
|
149
|
+
sourceTypeName: "${futureAddition.sourceTypeName}",
|
|
150
|
+
sourceFieldName: "${futureAddition.sourceFieldName}",
|
|
151
|
+
sourceName: "${futureAddition.sourceName}",
|
|
152
|
+
sourceArgs: ${(0, graphql_1.print)((0, utils_2.astFromValueUntyped)(futureAddition.sourceArgs))},
|
|
153
|
+
requiredSelectionSet: "${futureAddition.requiredSelectionSet}"
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
`));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
116
159
|
if (additionalTypeDefs?.length /* TODO || config.transforms?.length */) {
|
|
117
|
-
|
|
160
|
+
composedSchema ||= (0, graphql_1.buildSchema)(result.supergraphSdl, {
|
|
118
161
|
noLocation: true,
|
|
119
162
|
assumeValid: true,
|
|
120
163
|
assumeValidSDL: true,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { buildSchema, Kind, parse, print, visit, } from 'graphql';
|
|
2
|
-
import { composeSubgraphs, getAnnotatedSubgraphs, } from '@graphql-mesh/fusion-composition';
|
|
1
|
+
import { buildSchema, getNamedType, isInterfaceType, isNamedType, Kind, parse, print, visit, } from 'graphql';
|
|
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';
|
|
5
5
|
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
|
|
6
6
|
import { loadTypedefs } from '@graphql-tools/load';
|
|
7
7
|
import { mergeSchemas } from '@graphql-tools/schema';
|
|
8
|
-
import { printSchemaWithDirectives } from '@graphql-tools/utils';
|
|
8
|
+
import { astFromValueUntyped, printSchemaWithDirectives } from '@graphql-tools/utils';
|
|
9
9
|
import { fetch as defaultFetch } from '@whatwg-node/fetch';
|
|
10
10
|
const isDebug = ['1', 'y', 'yes', 't', 'true'].includes(String(process.env.DEBUG));
|
|
11
11
|
export async function getComposedSchemaFromConfig(config, logger) {
|
|
@@ -110,8 +110,51 @@ export async function getComposedSchemaFromConfig(config, logger) {
|
|
|
110
110
|
logger.error(`Unknown error: Supergraph is empty`);
|
|
111
111
|
process.exit(1);
|
|
112
112
|
}
|
|
113
|
+
let composedSchema;
|
|
114
|
+
if (futureAdditions.length) {
|
|
115
|
+
let futureAddition;
|
|
116
|
+
while ((futureAddition = futureAdditions.pop())) {
|
|
117
|
+
additionalTypeDefs ||= [];
|
|
118
|
+
composedSchema ||= buildSchema(result.supergraphSdl, {
|
|
119
|
+
noLocation: true,
|
|
120
|
+
assumeValid: true,
|
|
121
|
+
assumeValidSDL: true,
|
|
122
|
+
});
|
|
123
|
+
const sourceType = composedSchema.getType(futureAddition.sourceTypeName);
|
|
124
|
+
if (!sourceType) {
|
|
125
|
+
logger.error(`Target type ${futureAddition.sourceTypeName} not found`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
const sourceField = sourceType.getFields()[futureAddition.sourceFieldName];
|
|
129
|
+
if (!sourceField) {
|
|
130
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} not found`);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
const sourceReturnType = getNamedType(sourceField.type);
|
|
134
|
+
if (!isNamedType(sourceReturnType)) {
|
|
135
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} has no return type`);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
const interfaceOrType = isInterfaceType(composedSchema.getType(futureAddition.targetTypeName))
|
|
139
|
+
? 'interface'
|
|
140
|
+
: 'type';
|
|
141
|
+
additionalTypeDefs.push(parse(/* GraphQL */ `
|
|
142
|
+
extend ${interfaceOrType} ${futureAddition.targetTypeName} {
|
|
143
|
+
${futureAddition.targetFieldName}: ${sourceReturnType}
|
|
144
|
+
@additionalField
|
|
145
|
+
@resolveTo(
|
|
146
|
+
sourceTypeName: "${futureAddition.sourceTypeName}",
|
|
147
|
+
sourceFieldName: "${futureAddition.sourceFieldName}",
|
|
148
|
+
sourceName: "${futureAddition.sourceName}",
|
|
149
|
+
sourceArgs: ${print(astFromValueUntyped(futureAddition.sourceArgs))},
|
|
150
|
+
requiredSelectionSet: "${futureAddition.requiredSelectionSet}"
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
`));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
113
156
|
if (additionalTypeDefs?.length /* TODO || config.transforms?.length */) {
|
|
114
|
-
|
|
157
|
+
composedSchema ||= buildSchema(result.supergraphSdl, {
|
|
115
158
|
noLocation: true,
|
|
116
159
|
assumeValid: true,
|
|
117
160
|
assumeValidSDL: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/compose-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha-20241202162739-65f4d2fb102c00ad9ed40a4a2fc62ecc00e0c69c",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@graphql-mesh/types": "^0.103.5",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@commander-js/extra-typings": "^12.1.0",
|
|
11
|
-
"@graphql-mesh/fusion-composition": "
|
|
12
|
-
"@graphql-mesh/include": "
|
|
13
|
-
"@graphql-mesh/utils": "
|
|
11
|
+
"@graphql-mesh/fusion-composition": "workspace:^",
|
|
12
|
+
"@graphql-mesh/include": "workspace:^",
|
|
13
|
+
"@graphql-mesh/utils": "workspace:^",
|
|
14
14
|
"@graphql-tools/code-file-loader": "^8.1.7",
|
|
15
15
|
"@graphql-tools/graphql-file-loader": "^8.0.5",
|
|
16
16
|
"@graphql-tools/load": "^8.0.1",
|