@wundergraph/composition 0.39.2 → 0.40.0

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.
Files changed (43) hide show
  1. package/dist/errors/errors.d.ts +4 -6
  2. package/dist/errors/errors.js +19 -33
  3. package/dist/errors/errors.js.map +1 -1
  4. package/dist/errors/types.d.ts +16 -0
  5. package/dist/errors/{utils.js → types.js} +1 -1
  6. package/dist/errors/types.js.map +1 -0
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/schema-building/types.d.ts +7 -4
  10. package/dist/schema-building/types.js.map +1 -1
  11. package/dist/schema-building/utils.d.ts +3 -0
  12. package/dist/schema-building/utils.js +10 -2
  13. package/dist/schema-building/utils.js.map +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/utils/composition-version.js +1 -1
  16. package/dist/utils/string-constants.d.ts +4 -0
  17. package/dist/utils/string-constants.js +17 -3
  18. package/dist/utils/string-constants.js.map +1 -1
  19. package/dist/utils/types.d.ts +3 -6
  20. package/dist/utils/utils.d.ts +2 -4
  21. package/dist/utils/utils.js +31 -57
  22. package/dist/utils/utils.js.map +1 -1
  23. package/dist/v1/federation/federation-factory.d.ts +4 -5
  24. package/dist/v1/federation/federation-factory.js +65 -63
  25. package/dist/v1/federation/federation-factory.js.map +1 -1
  26. package/dist/v1/federation/utils.js +17 -17
  27. package/dist/v1/federation/utils.js.map +1 -1
  28. package/dist/v1/federation/walkers.js +2 -2
  29. package/dist/v1/federation/walkers.js.map +1 -1
  30. package/dist/v1/normalization/normalization-factory.d.ts +3 -5
  31. package/dist/v1/normalization/normalization-factory.js +176 -154
  32. package/dist/v1/normalization/normalization-factory.js.map +1 -1
  33. package/dist/v1/normalization/types.d.ts +1 -6
  34. package/dist/v1/normalization/utils.js +8 -8
  35. package/dist/v1/normalization/utils.js.map +1 -1
  36. package/dist/v1/normalization/walkers.js +8 -8
  37. package/dist/v1/normalization/walkers.js.map +1 -1
  38. package/dist/v1/schema-building/type-merging.d.ts +12 -6
  39. package/dist/v1/schema-building/type-merging.js +7 -9
  40. package/dist/v1/schema-building/type-merging.js.map +1 -1
  41. package/package.json +2 -2
  42. package/dist/errors/utils.d.ts +0 -4
  43. package/dist/errors/utils.js.map +0 -1
@@ -24,7 +24,6 @@ const integer_constants_1 = require("../utils/integer-constants");
24
24
  const string_constants_2 = require("../../utils/string-constants");
25
25
  const integer_constants_2 = require("../../utils/integer-constants");
26
26
  const utils_5 = require("../../utils/utils");
27
- const index_1 = require("graphql/index");
28
27
  const utils_6 = require("../../router-configuration/utils");
29
28
  function normalizeSubgraphFromString(subgraphSDL, noLocation = true) {
30
29
  const { error, documentNode } = (0, utils_1.safeParse)(subgraphSDL, noLocation);
@@ -76,7 +75,6 @@ class NormalizationFactory {
76
75
  originalTypeNameByRenamedTypeName = new Map();
77
76
  overridesByTargetSubgraphName = new Map();
78
77
  parentDefinitionDataByTypeName = new Map();
79
- parentsWithChildArguments = new Set();
80
78
  schemaData;
81
79
  referencedDirectiveNames = new Set();
82
80
  referencedTypeNames = new Set();
@@ -99,42 +97,27 @@ class NormalizationFactory {
99
97
  operationTypes: new Map(),
100
98
  };
101
99
  }
102
- validateInputNamedType(namedTypeName) {
103
- if (constants_1.BASE_SCALARS.has(namedTypeName)) {
104
- return { hasUnhandledError: false, typeString: '' };
105
- }
106
- const parentData = this.parentDefinitionDataByTypeName.get(namedTypeName);
107
- if (!parentData) {
108
- return { hasUnhandledError: false, typeString: '' };
109
- }
110
- switch (parentData.kind) {
111
- case graphql_1.Kind.ENUM_TYPE_DEFINITION:
112
- case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
113
- case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
114
- return { hasUnhandledError: false, typeString: '' };
115
- default:
116
- return { hasUnhandledError: true, typeString: (0, utils_5.kindToTypeString)(parentData.kind) };
117
- }
118
- }
119
- validateArguments(fieldData, fieldPath) {
120
- const invalidArguments = [];
121
- for (const [argumentName, argumentNode] of fieldData.argumentDataByArgumentName) {
122
- const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentNode.type);
123
- if (!constants_1.BASE_SCALARS.has(namedTypeName)) {
124
- this.referencedTypeNames.add(namedTypeName);
125
- }
126
- const { hasUnhandledError, typeString } = this.validateInputNamedType(namedTypeName);
127
- if (hasUnhandledError) {
128
- invalidArguments.push({
129
- argumentName,
130
- namedType: namedTypeName,
131
- typeString,
132
- typeName: (0, merge_1.printTypeNode)(argumentNode.type),
133
- });
100
+ validateArguments(fieldData, parentKind) {
101
+ for (const argumentData of fieldData.argumentDataByName.values()) {
102
+ const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentData.type);
103
+ if (constants_1.BASE_SCALARS.has(namedTypeName)) {
104
+ argumentData.namedTypeKind = graphql_1.Kind.SCALAR_TYPE_DEFINITION;
105
+ continue;
134
106
  }
135
- }
136
- if (invalidArguments.length > 0) {
137
- this.errors.push((0, errors_1.invalidArgumentsError)(fieldPath, invalidArguments));
107
+ const namedTypeData = this.parentDefinitionDataByTypeName.get(namedTypeName);
108
+ if (!namedTypeData) {
109
+ // undefined types are handled elsewhere
110
+ continue;
111
+ }
112
+ if ((0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
113
+ argumentData.namedTypeKind = namedTypeData.kind;
114
+ continue;
115
+ }
116
+ this.errors.push((0, errors_1.invalidNamedTypeError)({
117
+ data: argumentData,
118
+ namedTypeData,
119
+ nodeType: `${(0, utils_5.kindToNodeType)(parentKind)} field argument`,
120
+ }));
138
121
  }
139
122
  }
140
123
  isTypeNameRootType(typeName) {
@@ -379,13 +362,13 @@ class NormalizationFactory {
379
362
  return;
380
363
  }
381
364
  case graphql_1.Kind.FIELD_DEFINITION: {
382
- for (const [argumentName, argumentData] of data.argumentDataByArgumentName) {
365
+ for (const [argumentName, argumentData] of data.argumentDataByName) {
383
366
  this.validateDirectives(argumentData, `${data.originalParentTypeName}.${data.name}(${argumentName}: ...)`);
384
367
  }
385
368
  return;
386
369
  }
387
370
  case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
388
- for (const [inputValueName, inputValueData] of data.inputValueDataByValueName) {
371
+ for (const [inputValueName, inputValueData] of data.inputValueDataByName) {
389
372
  this.validateDirectives(inputValueData, `${data.name}.${inputValueName}`);
390
373
  }
391
374
  return;
@@ -393,7 +376,7 @@ class NormalizationFactory {
393
376
  case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
394
377
  // intentional fallthrough
395
378
  case graphql_1.Kind.OBJECT_TYPE_DEFINITION: {
396
- for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
379
+ for (const [fieldName, fieldData] of data.fieldDataByName) {
397
380
  this.validateDirectives(fieldData, `${data.name}.${fieldName}`);
398
381
  }
399
382
  return;
@@ -432,7 +415,7 @@ class NormalizationFactory {
432
415
  if (incomingExtensionType === types_1.ExtensionType.REAL) {
433
416
  return;
434
417
  }
435
- this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0, utils_5.kindToTypeString)(parentData.kind), parentData.name));
418
+ this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0, utils_5.kindToNodeType)(parentData.kind), parentData.name));
436
419
  return;
437
420
  }
438
421
  default: {
@@ -527,7 +510,6 @@ class NormalizationFactory {
527
510
  }
528
511
  const fieldName = node.name.value;
529
512
  const originalFieldPath = `${this.originalParentTypeName}.${fieldName}`;
530
- this.parentsWithChildArguments.add(this.originalParentTypeName);
531
513
  const duplicatedArguments = new Set();
532
514
  for (const argumentNode of node.arguments) {
533
515
  const argumentName = argumentNode.name.value;
@@ -666,8 +648,9 @@ class NormalizationFactory {
666
648
  const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
667
649
  const fieldCoords = `${this.originalParentTypeName}.${name}`;
668
650
  const { isExternal, isShareable } = (0, utils_4.isNodeExternalOrShareable)(node, !this.isSubgraphVersionTwo, directivesByDirectiveName);
651
+ const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(node.type);
669
652
  const fieldData = {
670
- argumentDataByArgumentName: argumentDataByArgumentName,
653
+ argumentDataByName: argumentDataByArgumentName,
671
654
  configureDescriptionDataBySubgraphName: new Map(),
672
655
  externalFieldDataBySubgraphName: new Map([
673
656
  [this.subgraphName, (0, utils_4.newExternalFieldData)(isExternal)],
@@ -677,7 +660,8 @@ class NormalizationFactory {
677
660
  isShareableBySubgraphName: new Map([[this.subgraphName, isShareable]]),
678
661
  kind: graphql_1.Kind.FIELD_DEFINITION,
679
662
  name,
680
- namedTypeName: (0, ast_1.getTypeNodeNamedTypeName)(node.type),
663
+ namedTypeKind: constants_1.BASE_SCALARS.has(namedTypeName) ? graphql_1.Kind.SCALAR_TYPE_DEFINITION : graphql_1.Kind.NULL,
664
+ namedTypeName,
681
665
  node: (0, ast_1.getMutableFieldNode)(node, fieldCoords, this.errors),
682
666
  originalParentTypeName: this.originalParentTypeName,
683
667
  persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
@@ -707,6 +691,7 @@ class NormalizationFactory {
707
691
  const federatedCoords = isArgument
708
692
  ? `${federatedParentTypeName}${fieldName ? `.${fieldName}` : ''}(${name}: ...)`
709
693
  : `${federatedParentTypeName}.${name}`;
694
+ const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(node.type);
710
695
  const inputValueData = {
711
696
  configureDescriptionDataBySubgraphName: new Map(),
712
697
  directivesByDirectiveName: this.extractDirectives(node, new Map()),
@@ -716,7 +701,8 @@ class NormalizationFactory {
716
701
  isArgument,
717
702
  kind: isArgument ? graphql_1.Kind.ARGUMENT : graphql_1.Kind.INPUT_VALUE_DEFINITION,
718
703
  name,
719
- namedTypeName: (0, ast_1.getTypeNodeNamedTypeName)(node.type),
704
+ namedTypeKind: constants_1.BASE_SCALARS.has(namedTypeName) ? graphql_1.Kind.SCALAR_TYPE_DEFINITION : graphql_1.Kind.NULL,
705
+ namedTypeName,
720
706
  node: (0, ast_1.getMutableInputValueNode)(node, originalParentTypeName, this.errors),
721
707
  originalCoords,
722
708
  originalParentTypeName: originalParentTypeName,
@@ -744,7 +730,7 @@ class NormalizationFactory {
744
730
  }
745
731
  if (parentData) {
746
732
  if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
747
- this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
733
+ this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
748
734
  return;
749
735
  }
750
736
  this.updateCompositeOutputDataByNode(node, parentData, extensionType);
@@ -754,7 +740,7 @@ class NormalizationFactory {
754
740
  configureDescriptionDataBySubgraphName: new Map(),
755
741
  directivesByDirectiveName,
756
742
  extensionType,
757
- fieldDataByFieldName: new Map(),
743
+ fieldDataByName: new Map(),
758
744
  implementedInterfaceTypeNames: this.extractImplementedInterfaceTypeNames(node, new Set()),
759
745
  isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
760
746
  isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
@@ -801,7 +787,7 @@ class NormalizationFactory {
801
787
  this.addInterfaceObjectFieldsByNode(node);
802
788
  if (parentData) {
803
789
  if (parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
804
- this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
790
+ this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
805
791
  return;
806
792
  }
807
793
  this.updateCompositeOutputDataByNode(node, parentData, extensionType);
@@ -814,7 +800,7 @@ class NormalizationFactory {
814
800
  configureDescriptionDataBySubgraphName: new Map(),
815
801
  directivesByDirectiveName,
816
802
  extensionType,
817
- fieldDataByFieldName: new Map(),
803
+ fieldDataByName: new Map(),
818
804
  implementedInterfaceTypeNames,
819
805
  isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
820
806
  isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
@@ -838,7 +824,7 @@ class NormalizationFactory {
838
824
  const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
839
825
  if (parentData) {
840
826
  if (parentData.kind !== graphql_1.Kind.ENUM_TYPE_DEFINITION) {
841
- this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
827
+ this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
842
828
  return;
843
829
  }
844
830
  this.setParentDataExtensionType(parentData, extensionType);
@@ -872,7 +858,7 @@ class NormalizationFactory {
872
858
  const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
873
859
  if (parentData) {
874
860
  if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
875
- this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
861
+ this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
876
862
  return;
877
863
  }
878
864
  this.setParentDataExtensionType(parentData, extensionType);
@@ -886,7 +872,7 @@ class NormalizationFactory {
886
872
  configureDescriptionDataBySubgraphName: new Map(),
887
873
  directivesByDirectiveName,
888
874
  extensionType,
889
- inputValueDataByValueName: new Map(),
875
+ inputValueDataByName: new Map(),
890
876
  isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
891
877
  kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
892
878
  name: typeName,
@@ -906,7 +892,7 @@ class NormalizationFactory {
906
892
  const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
907
893
  if (parentData) {
908
894
  if (parentData.kind !== graphql_1.Kind.SCALAR_TYPE_DEFINITION) {
909
- this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
895
+ this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
910
896
  return;
911
897
  }
912
898
  this.setParentDataExtensionType(parentData, extensionType);
@@ -963,7 +949,7 @@ class NormalizationFactory {
963
949
  this.addConcreteTypeNamesForUnion(node);
964
950
  if (parentData) {
965
951
  if (parentData.kind !== graphql_1.Kind.UNION_TYPE_DEFINITION) {
966
- this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
952
+ this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
967
953
  return;
968
954
  }
969
955
  this.setParentDataExtensionType(parentData, extensionType);
@@ -1054,7 +1040,7 @@ class NormalizationFactory {
1054
1040
  if (!isProvides) {
1055
1041
  return { fieldSetParentData: parentData };
1056
1042
  }
1057
- const fieldData = (0, utils_5.getOrThrowError)(parentData.fieldDataByFieldName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
1043
+ const fieldData = (0, utils_5.getOrThrowError)(parentData.fieldDataByName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
1058
1044
  const fieldNamedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
1059
1045
  const namedTypeData = this.parentDefinitionDataByTypeName.get(fieldNamedTypeName);
1060
1046
  // This error should never happen
@@ -1089,7 +1075,7 @@ class NormalizationFactory {
1089
1075
  let shouldDefineSelectionSet = true;
1090
1076
  let lastFieldName = directiveFieldName;
1091
1077
  let hasConditionalField = false;
1092
- (0, index_1.visit)(documentNode, {
1078
+ (0, graphql_1.visit)(documentNode, {
1093
1079
  Argument: {
1094
1080
  enter() {
1095
1081
  return false;
@@ -1101,28 +1087,28 @@ class NormalizationFactory {
1101
1087
  const parentTypeName = parentData.name;
1102
1088
  if (parentData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
1103
1089
  errorMessages.push((0, errors_1.invalidSelectionOnUnionErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName));
1104
- return index_1.BREAK;
1090
+ return graphql_1.BREAK;
1105
1091
  }
1106
1092
  const fieldName = node.name.value;
1107
1093
  const currentFieldCoords = `${parentTypeName}.${fieldName}`;
1108
1094
  nf.unvalidatedExternalFieldCoords.delete(currentFieldCoords);
1109
1095
  // If an object-like was just visited, a selection set should have been entered
1110
1096
  if (shouldDefineSelectionSet) {
1111
- errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, (0, utils_5.kindToTypeString)(parentData.kind)));
1112
- return index_1.BREAK;
1097
+ errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, (0, utils_5.kindToNodeType)(parentData.kind)));
1098
+ return graphql_1.BREAK;
1113
1099
  }
1114
1100
  fieldCoordsPath.push(currentFieldCoords);
1115
1101
  fieldPath.push(fieldName);
1116
1102
  lastFieldName = fieldName;
1117
- const fieldData = parentData.fieldDataByFieldName.get(fieldName);
1103
+ const fieldData = parentData.fieldDataByName.get(fieldName);
1118
1104
  // undefined if the field does not exist on the parent
1119
1105
  if (!fieldData) {
1120
1106
  errorMessages.push((0, errors_1.undefinedFieldInFieldSetErrorMessage)(fieldSet, parentTypeName, fieldName));
1121
- return index_1.BREAK;
1107
+ return graphql_1.BREAK;
1122
1108
  }
1123
1109
  if (definedFields[currentDepth].has(fieldName)) {
1124
1110
  errorMessages.push((0, errors_1.duplicateFieldInFieldSetErrorMessage)(fieldSet, currentFieldCoords));
1125
- return index_1.BREAK;
1111
+ return graphql_1.BREAK;
1126
1112
  }
1127
1113
  definedFields[currentDepth].add(fieldName);
1128
1114
  const { isDefinedExternal, isUnconditionallyProvided } = (0, utils_5.getOrThrowError)(fieldData.externalFieldDataBySubgraphName, nf.subgraphName, `${currentFieldCoords}.externalFieldDataBySubgraphName`);
@@ -1176,7 +1162,7 @@ class NormalizationFactory {
1176
1162
  if (!namedTypeData) {
1177
1163
  // Should not be possible to receive this error
1178
1164
  errorMessages.push((0, errors_1.unknownTypeInFieldSetErrorMessage)(fieldSet, currentFieldCoords, namedTypeName));
1179
- return index_1.BREAK;
1165
+ return graphql_1.BREAK;
1180
1166
  }
1181
1167
  // TODO isFieldConditional
1182
1168
  if (isDefinedExternal) {
@@ -1208,7 +1194,7 @@ class NormalizationFactory {
1208
1194
  const fieldCoordinates = fieldCoordsPath.length < 1 ? selectionSetParentData.name : fieldCoordsPath[fieldCoordsPath.length - 1];
1209
1195
  if (!node.typeCondition) {
1210
1196
  errorMessages.push((0, errors_1.inlineFragmentWithoutTypeConditionErrorMessage)(fieldSet, fieldCoordinates));
1211
- return index_1.BREAK;
1197
+ return graphql_1.BREAK;
1212
1198
  }
1213
1199
  const typeConditionName = node.typeCondition.name.value;
1214
1200
  // It's possible to infinitely define fragments
@@ -1219,12 +1205,12 @@ class NormalizationFactory {
1219
1205
  }
1220
1206
  if (!(0, utils_1.isKindAbstract)(parentData.kind)) {
1221
1207
  errorMessages.push((0, errors_1.invalidInlineFragmentTypeErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, parentTypeName));
1222
- return index_1.BREAK;
1208
+ return graphql_1.BREAK;
1223
1209
  }
1224
1210
  const fragmentNamedTypeData = nf.parentDefinitionDataByTypeName.get(typeConditionName);
1225
1211
  if (!fragmentNamedTypeData) {
1226
1212
  errorMessages.push((0, errors_1.unknownInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName));
1227
- return index_1.BREAK;
1213
+ return graphql_1.BREAK;
1228
1214
  }
1229
1215
  shouldDefineSelectionSet = true;
1230
1216
  switch (fragmentNamedTypeData.kind) {
@@ -1248,12 +1234,12 @@ class NormalizationFactory {
1248
1234
  return;
1249
1235
  }
1250
1236
  default: {
1251
- errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionTypeErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName, (0, utils_5.kindToTypeString)(fragmentNamedTypeData.kind)));
1252
- return index_1.BREAK;
1237
+ errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionTypeErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName, (0, utils_5.kindToNodeType)(fragmentNamedTypeData.kind)));
1238
+ return graphql_1.BREAK;
1253
1239
  }
1254
1240
  }
1255
- errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, (0, utils_5.kindToTypeString)(parentData.kind), parentTypeName));
1256
- return index_1.BREAK;
1241
+ errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, (0, utils_5.kindToNodeType)(parentData.kind), parentTypeName));
1242
+ return graphql_1.BREAK;
1257
1243
  },
1258
1244
  },
1259
1245
  SelectionSet: {
@@ -1263,32 +1249,32 @@ class NormalizationFactory {
1263
1249
  if (parentData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
1264
1250
  // Should never happen
1265
1251
  errorMessages.push((0, errors_1.unparsableFieldSetSelectionErrorMessage)(fieldSet, lastFieldName));
1266
- return index_1.BREAK;
1252
+ return graphql_1.BREAK;
1267
1253
  }
1268
- const fieldData = parentData.fieldDataByFieldName.get(lastFieldName);
1254
+ const fieldData = parentData.fieldDataByName.get(lastFieldName);
1269
1255
  if (!fieldData) {
1270
1256
  errorMessages.push((0, errors_1.undefinedFieldInFieldSetErrorMessage)(fieldSet, parentData.name, lastFieldName));
1271
- return index_1.BREAK;
1257
+ return graphql_1.BREAK;
1272
1258
  }
1273
1259
  const fieldNamedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
1274
1260
  // If the child is not found, it's a base scalar. Undefined types would have already been handled.
1275
1261
  const namedTypeData = nf.parentDefinitionDataByTypeName.get(fieldNamedTypeName);
1276
1262
  const childKind = namedTypeData ? namedTypeData.kind : graphql_1.Kind.SCALAR_TYPE_DEFINITION;
1277
- errorMessages.push((0, errors_1.invalidSelectionSetDefinitionErrorMessage)(fieldSet, fieldCoordsPath, fieldNamedTypeName, (0, utils_5.kindToTypeString)(childKind)));
1278
- return index_1.BREAK;
1263
+ errorMessages.push((0, errors_1.invalidSelectionSetDefinitionErrorMessage)(fieldSet, fieldCoordsPath, fieldNamedTypeName, (0, utils_5.kindToNodeType)(childKind)));
1264
+ return graphql_1.BREAK;
1279
1265
  }
1280
1266
  currentDepth += 1;
1281
1267
  shouldDefineSelectionSet = false;
1282
1268
  if (currentDepth < 0 || currentDepth >= parentDatas.length) {
1283
1269
  errorMessages.push((0, errors_1.unparsableFieldSetSelectionErrorMessage)(fieldSet, lastFieldName));
1284
- return index_1.BREAK;
1270
+ return graphql_1.BREAK;
1285
1271
  }
1286
1272
  definedFields.push(new Set());
1287
1273
  },
1288
1274
  leave() {
1289
1275
  if (shouldDefineSelectionSet) {
1290
1276
  const parentData = parentDatas[currentDepth + 1];
1291
- errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentData.name, (0, utils_5.kindToTypeString)(parentData.kind)));
1277
+ errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentData.name, (0, utils_5.kindToNodeType)(parentData.kind)));
1292
1278
  shouldDefineSelectionSet = false;
1293
1279
  }
1294
1280
  // Empty selection sets would be a parse error, so it is unnecessary to handle them
@@ -1368,7 +1354,7 @@ class NormalizationFactory {
1368
1354
  continue;
1369
1355
  }
1370
1356
  if (interfaceData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
1371
- invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0, utils_5.kindToTypeString)(interfaceData.kind));
1357
+ invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0, utils_5.kindToNodeType)(interfaceData.kind));
1372
1358
  continue;
1373
1359
  }
1374
1360
  if (data.name === interfaceData.name) {
@@ -1380,10 +1366,10 @@ class NormalizationFactory {
1380
1366
  unimplementedFields: [],
1381
1367
  };
1382
1368
  let hasErrors = false;
1383
- for (const [fieldName, interfaceField] of interfaceData.fieldDataByFieldName) {
1369
+ for (const [fieldName, interfaceField] of interfaceData.fieldDataByName) {
1384
1370
  this.unvalidatedExternalFieldCoords.delete(`${data.name}.${fieldName}`);
1385
1371
  let hasNestedErrors = false;
1386
- const fieldData = data.fieldDataByFieldName.get(fieldName);
1372
+ const fieldData = data.fieldDataByName.get(fieldName);
1387
1373
  if (!fieldData) {
1388
1374
  hasErrors = true;
1389
1375
  implementationErrors.unimplementedFields.push(fieldName);
@@ -1403,9 +1389,9 @@ class NormalizationFactory {
1403
1389
  invalidFieldImplementation.implementedResponseType = (0, merge_1.printTypeNode)(fieldData.node.type);
1404
1390
  }
1405
1391
  const handledArguments = new Set();
1406
- for (const [argumentName, interfaceArgument] of interfaceField.argumentDataByArgumentName) {
1392
+ for (const [argumentName, interfaceArgument] of interfaceField.argumentDataByName) {
1407
1393
  handledArguments.add(argumentName);
1408
- const containerArgument = fieldData.argumentDataByArgumentName.get(argumentName);
1394
+ const containerArgument = fieldData.argumentDataByName.get(argumentName);
1409
1395
  // The type implementing the interface must include all arguments with no variation for that argument
1410
1396
  if (!containerArgument) {
1411
1397
  hasErrors = true;
@@ -1423,7 +1409,7 @@ class NormalizationFactory {
1423
1409
  }
1424
1410
  }
1425
1411
  // Additional arguments must be optional (nullable)
1426
- for (const [argumentName, argumentData] of fieldData.argumentDataByArgumentName) {
1412
+ for (const [argumentName, argumentData] of fieldData.argumentDataByName) {
1427
1413
  if (handledArguments.has(argumentName)) {
1428
1414
  continue;
1429
1415
  }
@@ -1454,7 +1440,7 @@ class NormalizationFactory {
1454
1440
  this.errors.push((0, errors_1.selfImplementationError)(data.name));
1455
1441
  }
1456
1442
  if (implementationErrorsMap.size > 0) {
1457
- this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0, utils_5.kindToTypeString)(data.kind), implementationErrorsMap));
1443
+ this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0, utils_5.kindToNodeType)(data.kind), implementationErrorsMap));
1458
1444
  }
1459
1445
  }
1460
1446
  handleAuthenticatedDirective(data, parentTypeName) {
@@ -1817,7 +1803,7 @@ class NormalizationFactory {
1817
1803
  return;
1818
1804
  }
1819
1805
  const validEventDirectiveNames = this.getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode);
1820
- for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
1806
+ for (const [fieldName, fieldData] of data.fieldDataByName) {
1821
1807
  const fieldCoords = `${fieldData.originalParentTypeName}.${fieldName}`;
1822
1808
  const definedEventsDirectiveNames = new Set();
1823
1809
  for (const eventsDirectiveName of string_constants_1.EVENT_DIRECTIVE_NAMES) {
@@ -1892,11 +1878,11 @@ class NormalizationFactory {
1892
1878
  if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
1893
1879
  return false;
1894
1880
  }
1895
- if (data.fieldDataByFieldName.size != 1) {
1881
+ if (data.fieldDataByName.size != 1) {
1896
1882
  return false;
1897
1883
  }
1898
- for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
1899
- if (fieldData.argumentDataByArgumentName.size > 0) {
1884
+ for (const [fieldName, fieldData] of data.fieldDataByName) {
1885
+ if (fieldData.argumentDataByName.size > 0) {
1900
1886
  return false;
1901
1887
  }
1902
1888
  if (fieldName !== string_constants_2.SUCCESS) {
@@ -1912,10 +1898,10 @@ class NormalizationFactory {
1912
1898
  if (streamConfigurationInputData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
1913
1899
  return false;
1914
1900
  }
1915
- if (streamConfigurationInputData.inputValueDataByValueName.size != 3) {
1901
+ if (streamConfigurationInputData.inputValueDataByName.size != 3) {
1916
1902
  return false;
1917
1903
  }
1918
- for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByValueName) {
1904
+ for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByName) {
1919
1905
  switch (inputValueName) {
1920
1906
  case string_constants_2.CONSUMER_INACTIVE_THRESHOLD: {
1921
1907
  if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_INT) {
@@ -1971,7 +1957,7 @@ class NormalizationFactory {
1971
1957
  continue;
1972
1958
  }
1973
1959
  this.validateEventDrivenKeyDefinition(typeName, invalidKeyFieldSetsByEntityTypeName);
1974
- this.validateEventDrivenObjectFields(data.fieldDataByFieldName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath);
1960
+ this.validateEventDrivenObjectFields(data.fieldDataByName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath);
1975
1961
  }
1976
1962
  if (!this.isEdfsPublishResultValid()) {
1977
1963
  errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
@@ -2033,7 +2019,7 @@ class NormalizationFactory {
2033
2019
  continue;
2034
2020
  }
2035
2021
  if (memberData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
2036
- invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToTypeString)(memberData.kind)}"`);
2022
+ invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToNodeType)(memberData.kind)}"`);
2037
2023
  }
2038
2024
  }
2039
2025
  if (invalidMembers.length > 0) {
@@ -2117,13 +2103,13 @@ class NormalizationFactory {
2117
2103
  getInputObjectNodeByData(inputObjectDefinitionData) {
2118
2104
  inputObjectDefinitionData.node.description = inputObjectDefinitionData.description;
2119
2105
  inputObjectDefinitionData.node.directives = this.getValidFlattenedDirectiveArray(inputObjectDefinitionData.directivesByDirectiveName, inputObjectDefinitionData.name);
2120
- inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByValueName);
2106
+ inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByName);
2121
2107
  return inputObjectDefinitionData.node;
2122
2108
  }
2123
2109
  getCompositeOutputNodeByData(compositeOutputData) {
2124
2110
  compositeOutputData.node.description = compositeOutputData.description;
2125
2111
  compositeOutputData.node.directives = this.getValidFlattenedDirectiveArray(compositeOutputData.directivesByDirectiveName, compositeOutputData.name);
2126
- compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByFieldName);
2112
+ compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByName);
2127
2113
  compositeOutputData.node.interfaces = (0, utils_1.setToNamedTypeNodeArray)(compositeOutputData.implementedInterfaceTypeNames);
2128
2114
  return compositeOutputData.node;
2129
2115
  }
@@ -2166,10 +2152,10 @@ class NormalizationFactory {
2166
2152
  const externalExtensionFieldCoordsByRawFieldSet = new Map();
2167
2153
  let currentDepth = -1;
2168
2154
  let shouldDefineSelectionSet = true;
2169
- (0, index_1.visit)(keyFieldSetData.documentNode, {
2155
+ (0, graphql_1.visit)(keyFieldSetData.documentNode, {
2170
2156
  Argument: {
2171
2157
  enter() {
2172
- return index_1.BREAK;
2158
+ return graphql_1.BREAK;
2173
2159
  },
2174
2160
  },
2175
2161
  Field: {
@@ -2178,16 +2164,16 @@ class NormalizationFactory {
2178
2164
  const parentTypeName = parentData.name;
2179
2165
  // If a composite type was just visited, a selection set should have been entered
2180
2166
  if (shouldDefineSelectionSet) {
2181
- return index_1.BREAK;
2167
+ return graphql_1.BREAK;
2182
2168
  }
2183
2169
  const fieldName = node.name.value;
2184
2170
  const fieldCoords = `${parentTypeName}.${fieldName}`;
2185
2171
  // If a field declared @external is a key field, it is valid use of @external.
2186
2172
  nf.unvalidatedExternalFieldCoords.delete(fieldCoords);
2187
- const fieldData = parentData.fieldDataByFieldName.get(fieldName);
2173
+ const fieldData = parentData.fieldDataByName.get(fieldName);
2188
2174
  // undefined if the field does not exist on the parent
2189
- if (!fieldData || fieldData.argumentDataByArgumentName.size) {
2190
- return index_1.BREAK;
2175
+ if (!fieldData || fieldData.argumentDataByName.size) {
2176
+ return graphql_1.BREAK;
2191
2177
  }
2192
2178
  // Fields that form part of an entity key are intrinsically shareable
2193
2179
  fieldData.isShareableBySubgraphName.set(nf.subgraphName, true);
@@ -2231,7 +2217,7 @@ class NormalizationFactory {
2231
2217
  // The child could itself be a parent
2232
2218
  const namedTypeData = nf.parentDefinitionDataByTypeName.get(namedTypeName);
2233
2219
  if (!namedTypeData) {
2234
- return index_1.BREAK;
2220
+ return graphql_1.BREAK;
2235
2221
  }
2236
2222
  if (namedTypeData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
2237
2223
  shouldDefineSelectionSet = true;
@@ -2240,24 +2226,24 @@ class NormalizationFactory {
2240
2226
  }
2241
2227
  // interfaces and unions are invalid in a key directive
2242
2228
  if ((0, utils_1.isKindAbstract)(namedTypeData.kind)) {
2243
- return index_1.BREAK;
2229
+ return graphql_1.BREAK;
2244
2230
  }
2245
2231
  },
2246
2232
  },
2247
2233
  InlineFragment: {
2248
2234
  enter() {
2249
- return index_1.BREAK;
2235
+ return graphql_1.BREAK;
2250
2236
  },
2251
2237
  },
2252
2238
  SelectionSet: {
2253
2239
  enter() {
2254
2240
  if (!shouldDefineSelectionSet) {
2255
- return index_1.BREAK;
2241
+ return graphql_1.BREAK;
2256
2242
  }
2257
2243
  currentDepth += 1;
2258
2244
  shouldDefineSelectionSet = false;
2259
2245
  if (currentDepth < 0 || currentDepth >= parentDatas.length) {
2260
- return index_1.BREAK;
2246
+ return graphql_1.BREAK;
2261
2247
  }
2262
2248
  },
2263
2249
  leave() {
@@ -2379,63 +2365,101 @@ class NormalizationFactory {
2379
2365
  * */
2380
2366
  for (const data of this.invalidConfigureDescriptionNodeDatas) {
2381
2367
  if (!data.description) {
2382
- this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToTypeString)(data.kind), data.name));
2368
+ this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToNodeType)(data.kind), data.name));
2383
2369
  }
2384
2370
  }
2385
2371
  // Check all key field sets for @external fields to assess whether they are conditional
2386
2372
  this.evaluateExternalKeyFields();
2387
- for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
2388
- switch (parentDefinitionData.kind) {
2373
+ for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
2374
+ switch (parentData.kind) {
2389
2375
  case graphql_1.Kind.ENUM_TYPE_DEFINITION:
2390
- if (parentDefinitionData.enumValueDataByValueName.size < 1) {
2376
+ if (parentData.enumValueDataByValueName.size < 1) {
2391
2377
  this.errors.push((0, errors_1.noDefinedEnumValuesError)(parentTypeName));
2392
2378
  break;
2393
2379
  }
2394
- definitions.push(this.getEnumNodeByData(parentDefinitionData));
2380
+ definitions.push(this.getEnumNodeByData(parentData));
2395
2381
  break;
2396
2382
  case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
2397
- if (parentDefinitionData.inputValueDataByValueName.size < 1) {
2383
+ if (parentData.inputValueDataByName.size < 1) {
2398
2384
  this.errors.push((0, errors_1.noInputValueDefinitionsError)(parentTypeName));
2399
2385
  break;
2400
2386
  }
2401
- definitions.push(this.getInputObjectNodeByData(parentDefinitionData));
2387
+ for (const valueData of parentData.inputValueDataByName.values()) {
2388
+ // Base Scalars have already been set
2389
+ if (valueData.namedTypeKind !== graphql_1.Kind.NULL) {
2390
+ continue;
2391
+ }
2392
+ const namedTypeData = this.parentDefinitionDataByTypeName.get(valueData.namedTypeName);
2393
+ if (!namedTypeData) {
2394
+ // undefined types are handled elsewhere
2395
+ continue;
2396
+ }
2397
+ if (!(0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
2398
+ this.errors.push((0, errors_1.invalidNamedTypeError)({
2399
+ data: valueData,
2400
+ namedTypeData,
2401
+ nodeType: `${(0, utils_5.kindToNodeType)(parentData.kind)} field`,
2402
+ }));
2403
+ continue;
2404
+ }
2405
+ valueData.namedTypeKind = namedTypeData.kind;
2406
+ }
2407
+ definitions.push(this.getInputObjectNodeByData(parentData));
2402
2408
  break;
2403
2409
  case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
2404
2410
  // intentional fallthrough
2405
2411
  case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
2406
2412
  const isEntity = this.entityDataByTypeName.has(parentTypeName);
2407
2413
  const operationTypeNode = this.operationTypeNodeByTypeName.get(parentTypeName);
2408
- const isObject = parentDefinitionData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
2409
- if (this.isSubgraphVersionTwo && parentDefinitionData.extensionType === types_1.ExtensionType.EXTENDS) {
2414
+ const isObject = parentData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
2415
+ if (this.isSubgraphVersionTwo && parentData.extensionType === types_1.ExtensionType.EXTENDS) {
2410
2416
  // @extends is essentially ignored in V2. It was only propagated to handle @external key fields.
2411
- parentDefinitionData.extensionType = types_1.ExtensionType.NONE;
2417
+ parentData.extensionType = types_1.ExtensionType.NONE;
2412
2418
  }
2413
2419
  if (operationTypeNode) {
2414
- parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.SERVICE_FIELD);
2415
- parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.ENTITIES_FIELD);
2420
+ parentData.fieldDataByName.delete(string_constants_2.SERVICE_FIELD);
2421
+ parentData.fieldDataByName.delete(string_constants_2.ENTITIES_FIELD);
2416
2422
  }
2417
- (0, utils_4.removeInheritableDirectivesFromObjectParent)(parentDefinitionData);
2418
- if (this.parentsWithChildArguments.has(parentTypeName) || !isObject) {
2419
- const externalInterfaceFieldNames = [];
2420
- for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByFieldName) {
2421
- if (!isObject && fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
2422
- externalInterfaceFieldNames.push(fieldName);
2423
- }
2424
- // Arguments can only be fully validated once all parents types are known
2425
- this.validateArguments(fieldData, `${parentTypeName}.${fieldName}`);
2423
+ (0, utils_4.removeInheritableDirectivesFromObjectParent)(parentData);
2424
+ const externalInterfaceFieldNames = [];
2425
+ for (const [fieldName, fieldData] of parentData.fieldDataByName) {
2426
+ if (!isObject && fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
2427
+ externalInterfaceFieldNames.push(fieldName);
2426
2428
  }
2427
- // @external interface fields fails composition in V2; only propagate as a warning for V1.
2428
- if (externalInterfaceFieldNames.length > 0) {
2429
- this.isSubgraphVersionTwo
2430
- ? this.errors.push((0, errors_1.externalInterfaceFieldsError)(parentTypeName, externalInterfaceFieldNames))
2431
- : this.warnings.push((0, warnings_1.externalInterfaceFieldsWarning)(this.subgraphName, parentTypeName, externalInterfaceFieldNames));
2429
+ // Arguments can only be fully validated once all parents types are known
2430
+ this.validateArguments(fieldData, parentData.kind);
2431
+ // Base Scalars have already been set
2432
+ if (fieldData.namedTypeKind !== graphql_1.Kind.NULL) {
2433
+ continue;
2434
+ }
2435
+ const namedTypeData = this.parentDefinitionDataByTypeName.get(fieldData.namedTypeName);
2436
+ if (!namedTypeData) {
2437
+ // undefined types are handled elsewhere
2438
+ continue;
2432
2439
  }
2440
+ if (!(0, utils_4.isOutputNodeKind)(namedTypeData.kind)) {
2441
+ this.errors.push((0, errors_1.invalidNamedTypeError)({
2442
+ data: fieldData,
2443
+ namedTypeData,
2444
+ nodeType: `${(0, utils_5.kindToNodeType)(parentData.kind)} field`,
2445
+ }));
2446
+ continue;
2447
+ }
2448
+ fieldData.namedTypeKind = this.entityInterfaceDataByTypeName.get(namedTypeData.name)
2449
+ ? graphql_1.Kind.INTERFACE_TYPE_DEFINITION
2450
+ : namedTypeData.kind;
2451
+ }
2452
+ // @external interface fields fails composition in V2; only propagate as a warning for V1.
2453
+ if (externalInterfaceFieldNames.length > 0) {
2454
+ this.isSubgraphVersionTwo
2455
+ ? this.errors.push((0, errors_1.externalInterfaceFieldsError)(parentTypeName, externalInterfaceFieldNames))
2456
+ : this.warnings.push((0, warnings_1.externalInterfaceFieldsWarning)(this.subgraphName, parentTypeName, externalInterfaceFieldNames));
2433
2457
  }
2434
- const newParentTypeName = (0, utils_4.getParentTypeName)(parentDefinitionData);
2458
+ const newParentTypeName = (0, utils_4.getParentTypeName)(parentData);
2435
2459
  const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, newParentTypeName, () => (0, utils_6.newConfigurationData)(isEntity, parentTypeName));
2436
2460
  const entityInterfaceData = this.entityInterfaceDataByTypeName.get(parentTypeName);
2437
2461
  if (entityInterfaceData) {
2438
- entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentDefinitionData.fieldDataByFieldName.values());
2462
+ entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentData.fieldDataByName.values());
2439
2463
  const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(parentTypeName);
2440
2464
  if (concreteTypeNames) {
2441
2465
  (0, utils_5.addIterableValuesToSet)(concreteTypeNames, entityInterfaceData.concreteTypeNames);
@@ -2447,24 +2471,24 @@ class NormalizationFactory {
2447
2471
  if (events) {
2448
2472
  configurationData.events = events;
2449
2473
  }
2450
- this.addFieldNamesToConfigurationData(parentDefinitionData.fieldDataByFieldName, configurationData);
2451
- this.validateInterfaceImplementations(parentDefinitionData);
2452
- definitions.push(this.getCompositeOutputNodeByData(parentDefinitionData));
2474
+ this.addFieldNamesToConfigurationData(parentData.fieldDataByName, configurationData);
2475
+ this.validateInterfaceImplementations(parentData);
2476
+ definitions.push(this.getCompositeOutputNodeByData(parentData));
2453
2477
  // interfaces and objects must define at least one field
2454
- if (parentDefinitionData.fieldDataByFieldName.size < 1 && !(0, utils_2.isNodeQuery)(parentTypeName, operationTypeNode)) {
2455
- this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.kindToTypeString)(parentDefinitionData.kind), parentTypeName));
2478
+ if (parentData.fieldDataByName.size < 1 && !(0, utils_2.isNodeQuery)(parentTypeName, operationTypeNode)) {
2479
+ this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.kindToNodeType)(parentData.kind), parentTypeName));
2456
2480
  }
2457
2481
  break;
2458
2482
  case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
2459
- if (parentDefinitionData.extensionType === types_1.ExtensionType.REAL) {
2483
+ if (parentData.extensionType === types_1.ExtensionType.REAL) {
2460
2484
  this.errors.push((0, errors_1.noBaseScalarDefinitionError)(parentTypeName));
2461
2485
  break;
2462
2486
  }
2463
- definitions.push(this.getScalarNodeByData(parentDefinitionData));
2487
+ definitions.push(this.getScalarNodeByData(parentData));
2464
2488
  break;
2465
2489
  case graphql_1.Kind.UNION_TYPE_DEFINITION:
2466
- definitions.push(this.getUnionNodeByData(parentDefinitionData));
2467
- this.validateUnionMembers(parentDefinitionData);
2490
+ definitions.push(this.getUnionNodeByData(parentData));
2491
+ this.validateUnionMembers(parentData);
2468
2492
  break;
2469
2493
  default:
2470
2494
  throw (0, errors_1.unexpectedKindFatalError)(parentTypeName);
@@ -2513,20 +2537,18 @@ class NormalizationFactory {
2513
2537
  }
2514
2538
  for (const referencedTypeName of this.referencedTypeNames) {
2515
2539
  const parentData = this.parentDefinitionDataByTypeName.get(referencedTypeName);
2516
- if (parentData) {
2517
- if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
2518
- continue;
2519
- }
2520
- // There will be a run time error if a Field can return an interface without any Object implementations.
2521
- const implementationTypeNames = this.concreteTypeNamesByAbstractTypeName.get(referencedTypeName);
2522
- if (!implementationTypeNames || implementationTypeNames.size < 0) {
2523
- // Temporarily propagate as a warning until @inaccessible, entity interfaces and other such considerations are handled
2524
- this.warnings.push((0, warnings_1.unimplementedInterfaceOutputTypeWarning)(this.subgraphName, referencedTypeName));
2525
- }
2540
+ if (!parentData) {
2541
+ this.errors.push((0, errors_1.undefinedTypeError)(referencedTypeName));
2526
2542
  continue;
2527
2543
  }
2528
- if (!this.entityDataByTypeName.has(referencedTypeName)) {
2529
- this.errors.push((0, errors_1.undefinedTypeError)(referencedTypeName));
2544
+ if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
2545
+ continue;
2546
+ }
2547
+ // There will be a run time error if a field can return an Interface without any Object implementations.
2548
+ const implementationTypeNames = this.concreteTypeNamesByAbstractTypeName.get(referencedTypeName);
2549
+ if (!implementationTypeNames || implementationTypeNames.size < 0) {
2550
+ // Temporarily propagate as a warning until @inaccessible, entity interfaces and other such considerations are handled
2551
+ this.warnings.push((0, warnings_1.unimplementedInterfaceOutputTypeWarning)(this.subgraphName, referencedTypeName));
2530
2552
  }
2531
2553
  }
2532
2554
  const persistedDirectiveDefinitionDataByDirectiveName = new Map();