@graphql-mesh/compose-cli 1.3.0-alpha-20241126134439-29fdfea43e46db1ee9f6b1bf011494978b73ce46 → 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.
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getComposedSchemaFromConfig = getComposedSchemaFromConfig;
4
4
  const graphql_1 = require("graphql");
5
5
  const fusion_composition_1 = require("@graphql-mesh/fusion-composition");
6
+ const utils_1 = require("@graphql-mesh/utils");
7
+ const code_file_loader_1 = require("@graphql-tools/code-file-loader");
6
8
  const graphql_file_loader_1 = require("@graphql-tools/graphql-file-loader");
7
9
  const load_1 = require("@graphql-tools/load");
8
10
  const schema_1 = require("@graphql-tools/schema");
9
- const utils_1 = require("@graphql-tools/utils");
11
+ const utils_2 = require("@graphql-tools/utils");
10
12
  const fetch_1 = require("@whatwg-node/fetch");
11
13
  const isDebug = ['1', 'y', 'yes', 't', 'true'].includes(String(process.env.DEBUG));
12
14
  async function getComposedSchemaFromConfig(config, logger) {
@@ -41,16 +43,27 @@ async function getComposedSchemaFromConfig(config, logger) {
41
43
  }));
42
44
  let additionalTypeDefs;
43
45
  if (config.additionalTypeDefs != null) {
44
- const result = await (0, load_1.loadTypedefs)(config.additionalTypeDefs, {
45
- noLocation: true,
46
- assumeValid: true,
47
- assumeValidSDL: true,
48
- loaders: [new graphql_file_loader_1.GraphQLFileLoader()],
49
- });
50
46
  let additionalFieldDirectiveUsed = false;
51
- additionalTypeDefs = result
52
- .map(r => r.document || (0, graphql_1.parse)(r.rawSDL, { noLocation: true }))
53
- .map(doc => (0, graphql_1.visit)(doc, {
47
+ if (typeof config.additionalTypeDefs === 'string' && config.additionalTypeDefs?.includes(' ')) {
48
+ try {
49
+ additionalTypeDefs = [(0, utils_1.parseWithCache)(config.additionalTypeDefs)];
50
+ }
51
+ catch (e) {
52
+ logger.error(`Failed to parse additional type definitions: ${e.message || e}`);
53
+ process.exit(1);
54
+ }
55
+ }
56
+ else {
57
+ const result = await (0, load_1.loadTypedefs)(config.additionalTypeDefs, {
58
+ noLocation: true,
59
+ assumeValid: true,
60
+ assumeValidSDL: true,
61
+ loaders: [new code_file_loader_1.CodeFileLoader(), new graphql_file_loader_1.GraphQLFileLoader()],
62
+ });
63
+ additionalTypeDefs = result.map(source => source.document ||
64
+ (0, utils_1.parseWithCache)(source.rawSDL || (0, utils_2.printSchemaWithDirectives)(source.schema)));
65
+ }
66
+ additionalTypeDefs = additionalTypeDefs.map(doc => (0, graphql_1.visit)(doc, {
54
67
  [graphql_1.Kind.FIELD_DEFINITION](node) {
55
68
  additionalFieldDirectiveUsed = true;
56
69
  return {
@@ -136,7 +149,8 @@ async function getComposedSchemaFromConfig(config, logger) {
136
149
  sourceTypeName: "${futureAddition.sourceTypeName}",
137
150
  sourceFieldName: "${futureAddition.sourceFieldName}",
138
151
  sourceName: "${futureAddition.sourceName}",
139
- sourceArgs: ${(0, graphql_1.print)((0, utils_1.astFromValueUntyped)(futureAddition.sourceArgs))},
152
+ sourceArgs: ${(0, graphql_1.print)((0, utils_2.astFromValueUntyped)(futureAddition.sourceArgs))},
153
+ requiredSelectionSet: "${futureAddition.requiredSelectionSet}"
140
154
  )
141
155
  }
142
156
  `));
@@ -164,7 +178,7 @@ async function getComposedSchemaFromConfig(config, logger) {
164
178
  }
165
179
  }
166
180
  */
167
- return (0, utils_1.printSchemaWithDirectives)(composedSchema);
181
+ return (0, utils_2.printSchemaWithDirectives)(composedSchema);
168
182
  }
169
183
  return result.supergraphSdl;
170
184
  }
@@ -1,5 +1,7 @@
1
1
  import { buildSchema, getNamedType, isInterfaceType, isNamedType, Kind, parse, print, visit, } from 'graphql';
2
2
  import { composeSubgraphs, futureAdditions, getAnnotatedSubgraphs, } from '@graphql-mesh/fusion-composition';
3
+ import { parseWithCache } from '@graphql-mesh/utils';
4
+ import { CodeFileLoader } from '@graphql-tools/code-file-loader';
3
5
  import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
4
6
  import { loadTypedefs } from '@graphql-tools/load';
5
7
  import { mergeSchemas } from '@graphql-tools/schema';
@@ -38,16 +40,27 @@ export async function getComposedSchemaFromConfig(config, logger) {
38
40
  }));
39
41
  let additionalTypeDefs;
40
42
  if (config.additionalTypeDefs != null) {
41
- const result = await loadTypedefs(config.additionalTypeDefs, {
42
- noLocation: true,
43
- assumeValid: true,
44
- assumeValidSDL: true,
45
- loaders: [new GraphQLFileLoader()],
46
- });
47
43
  let additionalFieldDirectiveUsed = false;
48
- additionalTypeDefs = result
49
- .map(r => r.document || parse(r.rawSDL, { noLocation: true }))
50
- .map(doc => visit(doc, {
44
+ if (typeof config.additionalTypeDefs === 'string' && config.additionalTypeDefs?.includes(' ')) {
45
+ try {
46
+ additionalTypeDefs = [parseWithCache(config.additionalTypeDefs)];
47
+ }
48
+ catch (e) {
49
+ logger.error(`Failed to parse additional type definitions: ${e.message || e}`);
50
+ process.exit(1);
51
+ }
52
+ }
53
+ else {
54
+ const result = await loadTypedefs(config.additionalTypeDefs, {
55
+ noLocation: true,
56
+ assumeValid: true,
57
+ assumeValidSDL: true,
58
+ loaders: [new CodeFileLoader(), new GraphQLFileLoader()],
59
+ });
60
+ additionalTypeDefs = result.map(source => source.document ||
61
+ parseWithCache(source.rawSDL || printSchemaWithDirectives(source.schema)));
62
+ }
63
+ additionalTypeDefs = additionalTypeDefs.map(doc => visit(doc, {
51
64
  [Kind.FIELD_DEFINITION](node) {
52
65
  additionalFieldDirectiveUsed = true;
53
66
  return {
@@ -134,6 +147,7 @@ export async function getComposedSchemaFromConfig(config, logger) {
134
147
  sourceFieldName: "${futureAddition.sourceFieldName}",
135
148
  sourceName: "${futureAddition.sourceName}",
136
149
  sourceArgs: ${print(astFromValueUntyped(futureAddition.sourceArgs))},
150
+ requiredSelectionSet: "${futureAddition.requiredSelectionSet}"
137
151
  )
138
152
  }
139
153
  `));
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@graphql-mesh/compose-cli",
3
- "version": "1.3.0-alpha-20241126134439-29fdfea43e46db1ee9f6b1bf011494978b73ce46",
3
+ "version": "1.3.0-alpha-20241202162739-65f4d2fb102c00ad9ed40a4a2fc62ecc00e0c69c",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/types": "^0.103.4",
6
+ "@graphql-mesh/types": "^0.103.5",
7
7
  "graphql": "*"
8
8
  },
9
9
  "dependencies": {
10
10
  "@commander-js/extra-typings": "^12.1.0",
11
11
  "@graphql-mesh/fusion-composition": "workspace:^",
12
- "@graphql-mesh/include": "^0.2.3",
13
- "@graphql-mesh/utils": "^0.103.4",
14
- "@graphql-tools/graphql-file-loader": "8.0.4",
12
+ "@graphql-mesh/include": "workspace:^",
13
+ "@graphql-mesh/utils": "workspace:^",
14
+ "@graphql-tools/code-file-loader": "^8.1.7",
15
+ "@graphql-tools/graphql-file-loader": "^8.0.5",
15
16
  "@graphql-tools/load": "^8.0.1",
16
17
  "@graphql-tools/schema": "^10.0.5",
17
18
  "@graphql-tools/utils": "^10.6.0",