@graphql-mesh/compose-cli 1.4.1-alpha-20250306160526-5aaf1ff6d0e57417136b913cdc0b5efef26a6888 → 1.4.2-alpha-20250317135543-529da5294c3b7874d7bba222bb912ca47f46cdbc

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.
@@ -169,6 +169,37 @@ async function getComposedSchemaFromConfig(config, logger) {
169
169
  assumeValid: true,
170
170
  assumeValidSDL: true,
171
171
  });
172
+ // Fix extra additionalField annotations
173
+ if (composedSchema.getDirective('additionalField')) {
174
+ let composedSchemaAST = (0, utils_2.getDocumentNodeFromSchema)(composedSchema);
175
+ const typeInfo = new graphql_1.TypeInfo(composedSchema);
176
+ composedSchemaAST = (0, graphql_1.visit)(composedSchemaAST, (0, graphql_1.visitWithTypeInfo)(typeInfo, {
177
+ [graphql_1.Kind.FIELD_DEFINITION](node) {
178
+ const directiveNames = node.directives?.map(directive => directive.name.value);
179
+ if (directiveNames.includes('additionalField')) {
180
+ if (directiveNames.includes('join__field') || directiveNames.includes('source')) {
181
+ return {
182
+ ...node,
183
+ directives: node.directives?.filter(directive => directive.name.value !== 'additionalField'),
184
+ };
185
+ }
186
+ const type = typeInfo.getParentType();
187
+ if (type) {
188
+ const typeInOriginalSchema = composedSchema.getType(type.name);
189
+ if (typeInOriginalSchema && 'getFields' in typeInOriginalSchema) {
190
+ const field = typeInOriginalSchema.getFields()[node.name.value];
191
+ if (field) {
192
+ return {
193
+ ...node,
194
+ directives: node.directives?.filter(directive => directive.name.value !== 'additionalField'),
195
+ };
196
+ }
197
+ }
198
+ }
199
+ }
200
+ },
201
+ }));
202
+ }
172
203
  }
173
204
  /* TODO
174
205
  if (config.transforms?.length) {
@@ -1,11 +1,11 @@
1
- import { buildSchema, getNamedType, isInterfaceType, isNamedType, Kind, parse, print, visit, } from 'graphql';
1
+ import { buildSchema, getNamedType, isInterfaceType, isNamedType, Kind, parse, print, TypeInfo, visit, visitWithTypeInfo, } 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';
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 { astFromValueUntyped, printSchemaWithDirectives } from '@graphql-tools/utils';
8
+ import { astFromValueUntyped, getDocumentNodeFromSchema, 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) {
@@ -166,6 +166,37 @@ export async function getComposedSchemaFromConfig(config, logger) {
166
166
  assumeValid: true,
167
167
  assumeValidSDL: true,
168
168
  });
169
+ // Fix extra additionalField annotations
170
+ if (composedSchema.getDirective('additionalField')) {
171
+ let composedSchemaAST = getDocumentNodeFromSchema(composedSchema);
172
+ const typeInfo = new TypeInfo(composedSchema);
173
+ composedSchemaAST = visit(composedSchemaAST, visitWithTypeInfo(typeInfo, {
174
+ [Kind.FIELD_DEFINITION](node) {
175
+ const directiveNames = node.directives?.map(directive => directive.name.value);
176
+ if (directiveNames.includes('additionalField')) {
177
+ if (directiveNames.includes('join__field') || directiveNames.includes('source')) {
178
+ return {
179
+ ...node,
180
+ directives: node.directives?.filter(directive => directive.name.value !== 'additionalField'),
181
+ };
182
+ }
183
+ const type = typeInfo.getParentType();
184
+ if (type) {
185
+ const typeInOriginalSchema = composedSchema.getType(type.name);
186
+ if (typeInOriginalSchema && 'getFields' in typeInOriginalSchema) {
187
+ const field = typeInOriginalSchema.getFields()[node.name.value];
188
+ if (field) {
189
+ return {
190
+ ...node,
191
+ directives: node.directives?.filter(directive => directive.name.value !== 'additionalField'),
192
+ };
193
+ }
194
+ }
195
+ }
196
+ }
197
+ },
198
+ }));
199
+ }
169
200
  }
170
201
  /* TODO
171
202
  if (config.transforms?.length) {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@graphql-mesh/compose-cli",
3
- "version": "1.4.1-alpha-20250306160526-5aaf1ff6d0e57417136b913cdc0b5efef26a6888",
3
+ "version": "1.4.2-alpha-20250317135543-529da5294c3b7874d7bba222bb912ca47f46cdbc",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
7
7
  },
8
8
  "dependencies": {
9
9
  "@commander-js/extra-typings": "^13.0.0",
10
- "@graphql-mesh/fusion-composition": "0.8.1-alpha-20250306160526-5aaf1ff6d0e57417136b913cdc0b5efef26a6888",
11
- "@graphql-mesh/include": "0.3.1-alpha-20250306160526-5aaf1ff6d0e57417136b913cdc0b5efef26a6888",
10
+ "@graphql-mesh/fusion-composition": "^0.8.1",
11
+ "@graphql-mesh/include": "^0.3.1",
12
12
  "@graphql-mesh/string-interpolation": "^0.5.8",
13
- "@graphql-mesh/types": "0.104.1-alpha-20250306160526-5aaf1ff6d0e57417136b913cdc0b5efef26a6888",
14
- "@graphql-mesh/utils": "0.104.1-alpha-20250306160526-5aaf1ff6d0e57417136b913cdc0b5efef26a6888",
13
+ "@graphql-mesh/types": "^0.104.1",
14
+ "@graphql-mesh/utils": "^0.104.1",
15
15
  "@graphql-tools/code-file-loader": "^8.1.7",
16
16
  "@graphql-tools/graphql-file-loader": "^8.0.5",
17
17
  "@graphql-tools/load": "^8.0.1",