@graphql-mesh/compose-cli 1.2.7-alpha-20241126153139-b09c512c784bbd695bf2864660a4426d44f7387d → 1.3.0-alpha-20241126134439-29fdfea43e46db1ee9f6b1bf011494978b73ce46
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.
|
@@ -100,8 +100,50 @@ async function getComposedSchemaFromConfig(config, logger) {
|
|
|
100
100
|
logger.error(`Unknown error: Supergraph is empty`);
|
|
101
101
|
process.exit(1);
|
|
102
102
|
}
|
|
103
|
+
let composedSchema;
|
|
104
|
+
if (fusion_composition_1.futureAdditions.length) {
|
|
105
|
+
let futureAddition;
|
|
106
|
+
while ((futureAddition = fusion_composition_1.futureAdditions.pop())) {
|
|
107
|
+
additionalTypeDefs ||= [];
|
|
108
|
+
composedSchema ||= (0, graphql_1.buildSchema)(result.supergraphSdl, {
|
|
109
|
+
noLocation: true,
|
|
110
|
+
assumeValid: true,
|
|
111
|
+
assumeValidSDL: true,
|
|
112
|
+
});
|
|
113
|
+
const sourceType = composedSchema.getType(futureAddition.sourceTypeName);
|
|
114
|
+
if (!sourceType) {
|
|
115
|
+
logger.error(`Target type ${futureAddition.sourceTypeName} not found`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
const sourceField = sourceType.getFields()[futureAddition.sourceFieldName];
|
|
119
|
+
if (!sourceField) {
|
|
120
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} not found`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
const sourceReturnType = (0, graphql_1.getNamedType)(sourceField.type);
|
|
124
|
+
if (!(0, graphql_1.isNamedType)(sourceReturnType)) {
|
|
125
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} has no return type`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
const interfaceOrType = (0, graphql_1.isInterfaceType)(composedSchema.getType(futureAddition.targetTypeName))
|
|
129
|
+
? 'interface'
|
|
130
|
+
: 'type';
|
|
131
|
+
additionalTypeDefs.push((0, graphql_1.parse)(/* GraphQL */ `
|
|
132
|
+
extend ${interfaceOrType} ${futureAddition.targetTypeName} {
|
|
133
|
+
${futureAddition.targetFieldName}: ${sourceReturnType}
|
|
134
|
+
@additionalField
|
|
135
|
+
@resolveTo(
|
|
136
|
+
sourceTypeName: "${futureAddition.sourceTypeName}",
|
|
137
|
+
sourceFieldName: "${futureAddition.sourceFieldName}",
|
|
138
|
+
sourceName: "${futureAddition.sourceName}",
|
|
139
|
+
sourceArgs: ${(0, graphql_1.print)((0, utils_1.astFromValueUntyped)(futureAddition.sourceArgs))},
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
`));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
103
145
|
if (additionalTypeDefs?.length /* TODO || config.transforms?.length */) {
|
|
104
|
-
|
|
146
|
+
composedSchema ||= (0, graphql_1.buildSchema)(result.supergraphSdl, {
|
|
105
147
|
noLocation: true,
|
|
106
148
|
assumeValid: true,
|
|
107
149
|
assumeValidSDL: true,
|
|
@@ -1,9 +1,9 @@
|
|
|
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 { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
|
|
4
4
|
import { loadTypedefs } from '@graphql-tools/load';
|
|
5
5
|
import { mergeSchemas } from '@graphql-tools/schema';
|
|
6
|
-
import { printSchemaWithDirectives } from '@graphql-tools/utils';
|
|
6
|
+
import { astFromValueUntyped, printSchemaWithDirectives } from '@graphql-tools/utils';
|
|
7
7
|
import { fetch as defaultFetch } from '@whatwg-node/fetch';
|
|
8
8
|
const isDebug = ['1', 'y', 'yes', 't', 'true'].includes(String(process.env.DEBUG));
|
|
9
9
|
export async function getComposedSchemaFromConfig(config, logger) {
|
|
@@ -97,8 +97,50 @@ export async function getComposedSchemaFromConfig(config, logger) {
|
|
|
97
97
|
logger.error(`Unknown error: Supergraph is empty`);
|
|
98
98
|
process.exit(1);
|
|
99
99
|
}
|
|
100
|
+
let composedSchema;
|
|
101
|
+
if (futureAdditions.length) {
|
|
102
|
+
let futureAddition;
|
|
103
|
+
while ((futureAddition = futureAdditions.pop())) {
|
|
104
|
+
additionalTypeDefs ||= [];
|
|
105
|
+
composedSchema ||= buildSchema(result.supergraphSdl, {
|
|
106
|
+
noLocation: true,
|
|
107
|
+
assumeValid: true,
|
|
108
|
+
assumeValidSDL: true,
|
|
109
|
+
});
|
|
110
|
+
const sourceType = composedSchema.getType(futureAddition.sourceTypeName);
|
|
111
|
+
if (!sourceType) {
|
|
112
|
+
logger.error(`Target type ${futureAddition.sourceTypeName} not found`);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
const sourceField = sourceType.getFields()[futureAddition.sourceFieldName];
|
|
116
|
+
if (!sourceField) {
|
|
117
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} not found`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
const sourceReturnType = getNamedType(sourceField.type);
|
|
121
|
+
if (!isNamedType(sourceReturnType)) {
|
|
122
|
+
logger.error(`Target field ${futureAddition.sourceFieldName} has no return type`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
const interfaceOrType = isInterfaceType(composedSchema.getType(futureAddition.targetTypeName))
|
|
126
|
+
? 'interface'
|
|
127
|
+
: 'type';
|
|
128
|
+
additionalTypeDefs.push(parse(/* GraphQL */ `
|
|
129
|
+
extend ${interfaceOrType} ${futureAddition.targetTypeName} {
|
|
130
|
+
${futureAddition.targetFieldName}: ${sourceReturnType}
|
|
131
|
+
@additionalField
|
|
132
|
+
@resolveTo(
|
|
133
|
+
sourceTypeName: "${futureAddition.sourceTypeName}",
|
|
134
|
+
sourceFieldName: "${futureAddition.sourceFieldName}",
|
|
135
|
+
sourceName: "${futureAddition.sourceName}",
|
|
136
|
+
sourceArgs: ${print(astFromValueUntyped(futureAddition.sourceArgs))},
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
`));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
100
142
|
if (additionalTypeDefs?.length /* TODO || config.transforms?.length */) {
|
|
101
|
-
|
|
143
|
+
composedSchema ||= buildSchema(result.supergraphSdl, {
|
|
102
144
|
noLocation: true,
|
|
103
145
|
assumeValid: true,
|
|
104
146
|
assumeValidSDL: true,
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/compose-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha-20241126134439-29fdfea43e46db1ee9f6b1bf011494978b73ce46",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/types": "0.103.
|
|
6
|
+
"@graphql-mesh/types": "^0.103.4",
|
|
7
7
|
"graphql": "*"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@commander-js/extra-typings": "^12.1.0",
|
|
11
|
-
"@graphql-mesh/fusion-composition": "
|
|
11
|
+
"@graphql-mesh/fusion-composition": "workspace:^",
|
|
12
12
|
"@graphql-mesh/include": "^0.2.3",
|
|
13
|
-
"@graphql-mesh/utils": "0.103.
|
|
13
|
+
"@graphql-mesh/utils": "^0.103.4",
|
|
14
14
|
"@graphql-tools/graphql-file-loader": "8.0.4",
|
|
15
15
|
"@graphql-tools/load": "^8.0.1",
|
|
16
16
|
"@graphql-tools/schema": "^10.0.5",
|