@wundergraph/composition 0.39.2 → 0.41.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 (52) 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/router-configuration/types.d.ts +9 -1
  10. package/dist/schema-building/types.d.ts +7 -4
  11. package/dist/schema-building/types.js.map +1 -1
  12. package/dist/schema-building/utils.d.ts +3 -0
  13. package/dist/schema-building/utils.js +10 -2
  14. package/dist/schema-building/utils.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/dist/utils/composition-version.js +1 -1
  17. package/dist/utils/string-constants.d.ts +9 -0
  18. package/dist/utils/string-constants.js +23 -4
  19. package/dist/utils/string-constants.js.map +1 -1
  20. package/dist/utils/types.d.ts +3 -6
  21. package/dist/utils/utils.d.ts +2 -4
  22. package/dist/utils/utils.js +31 -57
  23. package/dist/utils/utils.js.map +1 -1
  24. package/dist/v1/federation/federation-factory.d.ts +4 -5
  25. package/dist/v1/federation/federation-factory.js +65 -63
  26. package/dist/v1/federation/federation-factory.js.map +1 -1
  27. package/dist/v1/federation/utils.js +17 -17
  28. package/dist/v1/federation/utils.js.map +1 -1
  29. package/dist/v1/federation/walkers.js +2 -2
  30. package/dist/v1/federation/walkers.js.map +1 -1
  31. package/dist/v1/normalization/directive-definition-data.d.ts +2 -0
  32. package/dist/v1/normalization/directive-definition-data.js +63 -1
  33. package/dist/v1/normalization/directive-definition-data.js.map +1 -1
  34. package/dist/v1/normalization/normalization-factory.d.ts +5 -5
  35. package/dist/v1/normalization/normalization-factory.js +258 -157
  36. package/dist/v1/normalization/normalization-factory.js.map +1 -1
  37. package/dist/v1/normalization/types.d.ts +1 -6
  38. package/dist/v1/normalization/utils.js +10 -8
  39. package/dist/v1/normalization/utils.js.map +1 -1
  40. package/dist/v1/normalization/walkers.js +8 -8
  41. package/dist/v1/normalization/walkers.js.map +1 -1
  42. package/dist/v1/schema-building/type-merging.d.ts +12 -6
  43. package/dist/v1/schema-building/type-merging.js +7 -9
  44. package/dist/v1/schema-building/type-merging.js.map +1 -1
  45. package/dist/v1/utils/constants.d.ts +2 -0
  46. package/dist/v1/utils/constants.js +59 -1
  47. package/dist/v1/utils/constants.js.map +1 -1
  48. package/dist/v1/utils/string-constants.js +2 -0
  49. package/dist/v1/utils/string-constants.js.map +1 -1
  50. package/package.json +2 -2
  51. package/dist/errors/utils.d.ts +0 -4
  52. 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) {
@@ -1723,6 +1709,77 @@ class NormalizationFactory {
1723
1709
  : {}),
1724
1710
  };
1725
1711
  }
1712
+ getRedisPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
1713
+ const channels = [];
1714
+ let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
1715
+ for (const argumentNode of directive.arguments || []) {
1716
+ switch (argumentNode.name.value) {
1717
+ case string_constants_2.CHANNEL: {
1718
+ if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
1719
+ errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_2.CHANNEL));
1720
+ continue;
1721
+ }
1722
+ (0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
1723
+ channels.push(argumentNode.value.value);
1724
+ break;
1725
+ }
1726
+ case string_constants_2.PROVIDER_ID: {
1727
+ if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
1728
+ errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
1729
+ continue;
1730
+ }
1731
+ providerId = argumentNode.value.value;
1732
+ break;
1733
+ }
1734
+ }
1735
+ }
1736
+ if (errorMessages.length > 0) {
1737
+ return;
1738
+ }
1739
+ return { fieldName, providerId, providerType: string_constants_2.PROVIDER_TYPE_REDIS, channels, type: string_constants_2.PUBLISH };
1740
+ }
1741
+ getRedisSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
1742
+ const channels = [];
1743
+ let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
1744
+ for (const argumentNode of directive.arguments || []) {
1745
+ switch (argumentNode.name.value) {
1746
+ case string_constants_2.CHANNELS: {
1747
+ //@TODO list coercion
1748
+ if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
1749
+ errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_2.CHANNELS));
1750
+ continue;
1751
+ }
1752
+ for (const value of argumentNode.value.values) {
1753
+ if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
1754
+ errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_2.CHANNELS));
1755
+ break;
1756
+ }
1757
+ (0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
1758
+ channels.push(value.value);
1759
+ }
1760
+ break;
1761
+ }
1762
+ case string_constants_2.PROVIDER_ID: {
1763
+ if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
1764
+ errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
1765
+ continue;
1766
+ }
1767
+ providerId = argumentNode.value.value;
1768
+ break;
1769
+ }
1770
+ }
1771
+ }
1772
+ if (errorMessages.length > 0) {
1773
+ return;
1774
+ }
1775
+ return {
1776
+ fieldName,
1777
+ providerId,
1778
+ providerType: string_constants_2.PROVIDER_TYPE_REDIS,
1779
+ channels,
1780
+ type: string_constants_2.SUBSCRIBE,
1781
+ };
1782
+ }
1726
1783
  validateSubscriptionFilterDirectiveLocation(node) {
1727
1784
  if (!node.directives) {
1728
1785
  return;
@@ -1769,6 +1826,14 @@ class NormalizationFactory {
1769
1826
  eventConfiguration = this.getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
1770
1827
  break;
1771
1828
  }
1829
+ case string_constants_2.EDFS_REDIS_PUBLISH: {
1830
+ eventConfiguration = this.getRedisPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
1831
+ break;
1832
+ }
1833
+ case string_constants_2.EDFS_REDIS_SUBSCRIBE: {
1834
+ eventConfiguration = this.getRedisSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
1835
+ break;
1836
+ }
1772
1837
  default:
1773
1838
  continue;
1774
1839
  }
@@ -1786,11 +1851,11 @@ class NormalizationFactory {
1786
1851
  getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode) {
1787
1852
  switch (operationTypeNode) {
1788
1853
  case graphql_1.OperationTypeNode.MUTATION:
1789
- return new Set([string_constants_2.EDFS_KAFKA_PUBLISH, string_constants_2.EDFS_NATS_PUBLISH, string_constants_2.EDFS_NATS_REQUEST]);
1854
+ return new Set([string_constants_2.EDFS_KAFKA_PUBLISH, string_constants_2.EDFS_NATS_PUBLISH, string_constants_2.EDFS_NATS_REQUEST, string_constants_2.EDFS_REDIS_PUBLISH]);
1790
1855
  case graphql_1.OperationTypeNode.QUERY:
1791
1856
  return new Set([string_constants_2.EDFS_NATS_REQUEST]);
1792
1857
  case graphql_1.OperationTypeNode.SUBSCRIPTION:
1793
- return new Set([string_constants_2.EDFS_KAFKA_SUBSCRIBE, string_constants_2.EDFS_NATS_SUBSCRIBE]);
1858
+ return new Set([string_constants_2.EDFS_KAFKA_SUBSCRIBE, string_constants_2.EDFS_NATS_SUBSCRIBE, string_constants_2.EDFS_REDIS_SUBSCRIBE]);
1794
1859
  }
1795
1860
  }
1796
1861
  getOperationTypeNodeForRootTypeName(parentTypeName) {
@@ -1817,7 +1882,7 @@ class NormalizationFactory {
1817
1882
  return;
1818
1883
  }
1819
1884
  const validEventDirectiveNames = this.getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode);
1820
- for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
1885
+ for (const [fieldName, fieldData] of data.fieldDataByName) {
1821
1886
  const fieldCoords = `${fieldData.originalParentTypeName}.${fieldName}`;
1822
1887
  const definedEventsDirectiveNames = new Set();
1823
1888
  for (const eventsDirectiveName of string_constants_1.EVENT_DIRECTIVE_NAMES) {
@@ -1892,11 +1957,11 @@ class NormalizationFactory {
1892
1957
  if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
1893
1958
  return false;
1894
1959
  }
1895
- if (data.fieldDataByFieldName.size != 1) {
1960
+ if (data.fieldDataByName.size != 1) {
1896
1961
  return false;
1897
1962
  }
1898
- for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
1899
- if (fieldData.argumentDataByArgumentName.size > 0) {
1963
+ for (const [fieldName, fieldData] of data.fieldDataByName) {
1964
+ if (fieldData.argumentDataByName.size > 0) {
1900
1965
  return false;
1901
1966
  }
1902
1967
  if (fieldName !== string_constants_2.SUCCESS) {
@@ -1912,10 +1977,10 @@ class NormalizationFactory {
1912
1977
  if (streamConfigurationInputData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
1913
1978
  return false;
1914
1979
  }
1915
- if (streamConfigurationInputData.inputValueDataByValueName.size != 3) {
1980
+ if (streamConfigurationInputData.inputValueDataByName.size != 3) {
1916
1981
  return false;
1917
1982
  }
1918
- for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByValueName) {
1983
+ for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByName) {
1919
1984
  switch (inputValueName) {
1920
1985
  case string_constants_2.CONSUMER_INACTIVE_THRESHOLD: {
1921
1986
  if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_INT) {
@@ -1971,7 +2036,7 @@ class NormalizationFactory {
1971
2036
  continue;
1972
2037
  }
1973
2038
  this.validateEventDrivenKeyDefinition(typeName, invalidKeyFieldSetsByEntityTypeName);
1974
- this.validateEventDrivenObjectFields(data.fieldDataByFieldName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath);
2039
+ this.validateEventDrivenObjectFields(data.fieldDataByName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath);
1975
2040
  }
1976
2041
  if (!this.isEdfsPublishResultValid()) {
1977
2042
  errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
@@ -2033,7 +2098,7 @@ class NormalizationFactory {
2033
2098
  continue;
2034
2099
  }
2035
2100
  if (memberData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
2036
- invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToTypeString)(memberData.kind)}"`);
2101
+ invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToNodeType)(memberData.kind)}"`);
2037
2102
  }
2038
2103
  }
2039
2104
  if (invalidMembers.length > 0) {
@@ -2117,13 +2182,13 @@ class NormalizationFactory {
2117
2182
  getInputObjectNodeByData(inputObjectDefinitionData) {
2118
2183
  inputObjectDefinitionData.node.description = inputObjectDefinitionData.description;
2119
2184
  inputObjectDefinitionData.node.directives = this.getValidFlattenedDirectiveArray(inputObjectDefinitionData.directivesByDirectiveName, inputObjectDefinitionData.name);
2120
- inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByValueName);
2185
+ inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByName);
2121
2186
  return inputObjectDefinitionData.node;
2122
2187
  }
2123
2188
  getCompositeOutputNodeByData(compositeOutputData) {
2124
2189
  compositeOutputData.node.description = compositeOutputData.description;
2125
2190
  compositeOutputData.node.directives = this.getValidFlattenedDirectiveArray(compositeOutputData.directivesByDirectiveName, compositeOutputData.name);
2126
- compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByFieldName);
2191
+ compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByName);
2127
2192
  compositeOutputData.node.interfaces = (0, utils_1.setToNamedTypeNodeArray)(compositeOutputData.implementedInterfaceTypeNames);
2128
2193
  return compositeOutputData.node;
2129
2194
  }
@@ -2166,10 +2231,10 @@ class NormalizationFactory {
2166
2231
  const externalExtensionFieldCoordsByRawFieldSet = new Map();
2167
2232
  let currentDepth = -1;
2168
2233
  let shouldDefineSelectionSet = true;
2169
- (0, index_1.visit)(keyFieldSetData.documentNode, {
2234
+ (0, graphql_1.visit)(keyFieldSetData.documentNode, {
2170
2235
  Argument: {
2171
2236
  enter() {
2172
- return index_1.BREAK;
2237
+ return graphql_1.BREAK;
2173
2238
  },
2174
2239
  },
2175
2240
  Field: {
@@ -2178,16 +2243,16 @@ class NormalizationFactory {
2178
2243
  const parentTypeName = parentData.name;
2179
2244
  // If a composite type was just visited, a selection set should have been entered
2180
2245
  if (shouldDefineSelectionSet) {
2181
- return index_1.BREAK;
2246
+ return graphql_1.BREAK;
2182
2247
  }
2183
2248
  const fieldName = node.name.value;
2184
2249
  const fieldCoords = `${parentTypeName}.${fieldName}`;
2185
2250
  // If a field declared @external is a key field, it is valid use of @external.
2186
2251
  nf.unvalidatedExternalFieldCoords.delete(fieldCoords);
2187
- const fieldData = parentData.fieldDataByFieldName.get(fieldName);
2252
+ const fieldData = parentData.fieldDataByName.get(fieldName);
2188
2253
  // undefined if the field does not exist on the parent
2189
- if (!fieldData || fieldData.argumentDataByArgumentName.size) {
2190
- return index_1.BREAK;
2254
+ if (!fieldData || fieldData.argumentDataByName.size) {
2255
+ return graphql_1.BREAK;
2191
2256
  }
2192
2257
  // Fields that form part of an entity key are intrinsically shareable
2193
2258
  fieldData.isShareableBySubgraphName.set(nf.subgraphName, true);
@@ -2231,7 +2296,7 @@ class NormalizationFactory {
2231
2296
  // The child could itself be a parent
2232
2297
  const namedTypeData = nf.parentDefinitionDataByTypeName.get(namedTypeName);
2233
2298
  if (!namedTypeData) {
2234
- return index_1.BREAK;
2299
+ return graphql_1.BREAK;
2235
2300
  }
2236
2301
  if (namedTypeData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
2237
2302
  shouldDefineSelectionSet = true;
@@ -2240,24 +2305,24 @@ class NormalizationFactory {
2240
2305
  }
2241
2306
  // interfaces and unions are invalid in a key directive
2242
2307
  if ((0, utils_1.isKindAbstract)(namedTypeData.kind)) {
2243
- return index_1.BREAK;
2308
+ return graphql_1.BREAK;
2244
2309
  }
2245
2310
  },
2246
2311
  },
2247
2312
  InlineFragment: {
2248
2313
  enter() {
2249
- return index_1.BREAK;
2314
+ return graphql_1.BREAK;
2250
2315
  },
2251
2316
  },
2252
2317
  SelectionSet: {
2253
2318
  enter() {
2254
2319
  if (!shouldDefineSelectionSet) {
2255
- return index_1.BREAK;
2320
+ return graphql_1.BREAK;
2256
2321
  }
2257
2322
  currentDepth += 1;
2258
2323
  shouldDefineSelectionSet = false;
2259
2324
  if (currentDepth < 0 || currentDepth >= parentDatas.length) {
2260
- return index_1.BREAK;
2325
+ return graphql_1.BREAK;
2261
2326
  }
2262
2327
  },
2263
2328
  leave() {
@@ -2379,63 +2444,101 @@ class NormalizationFactory {
2379
2444
  * */
2380
2445
  for (const data of this.invalidConfigureDescriptionNodeDatas) {
2381
2446
  if (!data.description) {
2382
- this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToTypeString)(data.kind), data.name));
2447
+ this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToNodeType)(data.kind), data.name));
2383
2448
  }
2384
2449
  }
2385
2450
  // Check all key field sets for @external fields to assess whether they are conditional
2386
2451
  this.evaluateExternalKeyFields();
2387
- for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
2388
- switch (parentDefinitionData.kind) {
2452
+ for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
2453
+ switch (parentData.kind) {
2389
2454
  case graphql_1.Kind.ENUM_TYPE_DEFINITION:
2390
- if (parentDefinitionData.enumValueDataByValueName.size < 1) {
2455
+ if (parentData.enumValueDataByValueName.size < 1) {
2391
2456
  this.errors.push((0, errors_1.noDefinedEnumValuesError)(parentTypeName));
2392
2457
  break;
2393
2458
  }
2394
- definitions.push(this.getEnumNodeByData(parentDefinitionData));
2459
+ definitions.push(this.getEnumNodeByData(parentData));
2395
2460
  break;
2396
2461
  case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
2397
- if (parentDefinitionData.inputValueDataByValueName.size < 1) {
2462
+ if (parentData.inputValueDataByName.size < 1) {
2398
2463
  this.errors.push((0, errors_1.noInputValueDefinitionsError)(parentTypeName));
2399
2464
  break;
2400
2465
  }
2401
- definitions.push(this.getInputObjectNodeByData(parentDefinitionData));
2466
+ for (const valueData of parentData.inputValueDataByName.values()) {
2467
+ // Base Scalars have already been set
2468
+ if (valueData.namedTypeKind !== graphql_1.Kind.NULL) {
2469
+ continue;
2470
+ }
2471
+ const namedTypeData = this.parentDefinitionDataByTypeName.get(valueData.namedTypeName);
2472
+ if (!namedTypeData) {
2473
+ // undefined types are handled elsewhere
2474
+ continue;
2475
+ }
2476
+ if (!(0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
2477
+ this.errors.push((0, errors_1.invalidNamedTypeError)({
2478
+ data: valueData,
2479
+ namedTypeData,
2480
+ nodeType: `${(0, utils_5.kindToNodeType)(parentData.kind)} field`,
2481
+ }));
2482
+ continue;
2483
+ }
2484
+ valueData.namedTypeKind = namedTypeData.kind;
2485
+ }
2486
+ definitions.push(this.getInputObjectNodeByData(parentData));
2402
2487
  break;
2403
2488
  case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
2404
2489
  // intentional fallthrough
2405
2490
  case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
2406
2491
  const isEntity = this.entityDataByTypeName.has(parentTypeName);
2407
2492
  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) {
2493
+ const isObject = parentData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
2494
+ if (this.isSubgraphVersionTwo && parentData.extensionType === types_1.ExtensionType.EXTENDS) {
2410
2495
  // @extends is essentially ignored in V2. It was only propagated to handle @external key fields.
2411
- parentDefinitionData.extensionType = types_1.ExtensionType.NONE;
2496
+ parentData.extensionType = types_1.ExtensionType.NONE;
2412
2497
  }
2413
2498
  if (operationTypeNode) {
2414
- parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.SERVICE_FIELD);
2415
- parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.ENTITIES_FIELD);
2416
- }
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}`);
2499
+ parentData.fieldDataByName.delete(string_constants_2.SERVICE_FIELD);
2500
+ parentData.fieldDataByName.delete(string_constants_2.ENTITIES_FIELD);
2501
+ }
2502
+ (0, utils_4.removeInheritableDirectivesFromObjectParent)(parentData);
2503
+ const externalInterfaceFieldNames = [];
2504
+ for (const [fieldName, fieldData] of parentData.fieldDataByName) {
2505
+ if (!isObject && fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
2506
+ externalInterfaceFieldNames.push(fieldName);
2507
+ }
2508
+ // Arguments can only be fully validated once all parents types are known
2509
+ this.validateArguments(fieldData, parentData.kind);
2510
+ // Base Scalars have already been set
2511
+ if (fieldData.namedTypeKind !== graphql_1.Kind.NULL) {
2512
+ continue;
2513
+ }
2514
+ const namedTypeData = this.parentDefinitionDataByTypeName.get(fieldData.namedTypeName);
2515
+ if (!namedTypeData) {
2516
+ // undefined types are handled elsewhere
2517
+ continue;
2426
2518
  }
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));
2519
+ if (!(0, utils_4.isOutputNodeKind)(namedTypeData.kind)) {
2520
+ this.errors.push((0, errors_1.invalidNamedTypeError)({
2521
+ data: fieldData,
2522
+ namedTypeData,
2523
+ nodeType: `${(0, utils_5.kindToNodeType)(parentData.kind)} field`,
2524
+ }));
2525
+ continue;
2432
2526
  }
2527
+ fieldData.namedTypeKind = this.entityInterfaceDataByTypeName.get(namedTypeData.name)
2528
+ ? graphql_1.Kind.INTERFACE_TYPE_DEFINITION
2529
+ : namedTypeData.kind;
2433
2530
  }
2434
- const newParentTypeName = (0, utils_4.getParentTypeName)(parentDefinitionData);
2531
+ // @external interface fields fails composition in V2; only propagate as a warning for V1.
2532
+ if (externalInterfaceFieldNames.length > 0) {
2533
+ this.isSubgraphVersionTwo
2534
+ ? this.errors.push((0, errors_1.externalInterfaceFieldsError)(parentTypeName, externalInterfaceFieldNames))
2535
+ : this.warnings.push((0, warnings_1.externalInterfaceFieldsWarning)(this.subgraphName, parentTypeName, externalInterfaceFieldNames));
2536
+ }
2537
+ const newParentTypeName = (0, utils_4.getParentTypeName)(parentData);
2435
2538
  const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, newParentTypeName, () => (0, utils_6.newConfigurationData)(isEntity, parentTypeName));
2436
2539
  const entityInterfaceData = this.entityInterfaceDataByTypeName.get(parentTypeName);
2437
2540
  if (entityInterfaceData) {
2438
- entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentDefinitionData.fieldDataByFieldName.values());
2541
+ entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentData.fieldDataByName.values());
2439
2542
  const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(parentTypeName);
2440
2543
  if (concreteTypeNames) {
2441
2544
  (0, utils_5.addIterableValuesToSet)(concreteTypeNames, entityInterfaceData.concreteTypeNames);
@@ -2447,24 +2550,24 @@ class NormalizationFactory {
2447
2550
  if (events) {
2448
2551
  configurationData.events = events;
2449
2552
  }
2450
- this.addFieldNamesToConfigurationData(parentDefinitionData.fieldDataByFieldName, configurationData);
2451
- this.validateInterfaceImplementations(parentDefinitionData);
2452
- definitions.push(this.getCompositeOutputNodeByData(parentDefinitionData));
2553
+ this.addFieldNamesToConfigurationData(parentData.fieldDataByName, configurationData);
2554
+ this.validateInterfaceImplementations(parentData);
2555
+ definitions.push(this.getCompositeOutputNodeByData(parentData));
2453
2556
  // 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));
2557
+ if (parentData.fieldDataByName.size < 1 && !(0, utils_2.isNodeQuery)(parentTypeName, operationTypeNode)) {
2558
+ this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.kindToNodeType)(parentData.kind), parentTypeName));
2456
2559
  }
2457
2560
  break;
2458
2561
  case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
2459
- if (parentDefinitionData.extensionType === types_1.ExtensionType.REAL) {
2562
+ if (parentData.extensionType === types_1.ExtensionType.REAL) {
2460
2563
  this.errors.push((0, errors_1.noBaseScalarDefinitionError)(parentTypeName));
2461
2564
  break;
2462
2565
  }
2463
- definitions.push(this.getScalarNodeByData(parentDefinitionData));
2566
+ definitions.push(this.getScalarNodeByData(parentData));
2464
2567
  break;
2465
2568
  case graphql_1.Kind.UNION_TYPE_DEFINITION:
2466
- definitions.push(this.getUnionNodeByData(parentDefinitionData));
2467
- this.validateUnionMembers(parentDefinitionData);
2569
+ definitions.push(this.getUnionNodeByData(parentData));
2570
+ this.validateUnionMembers(parentData);
2468
2571
  break;
2469
2572
  default:
2470
2573
  throw (0, errors_1.unexpectedKindFatalError)(parentTypeName);
@@ -2513,20 +2616,18 @@ class NormalizationFactory {
2513
2616
  }
2514
2617
  for (const referencedTypeName of this.referencedTypeNames) {
2515
2618
  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
- }
2619
+ if (!parentData) {
2620
+ this.errors.push((0, errors_1.undefinedTypeError)(referencedTypeName));
2526
2621
  continue;
2527
2622
  }
2528
- if (!this.entityDataByTypeName.has(referencedTypeName)) {
2529
- this.errors.push((0, errors_1.undefinedTypeError)(referencedTypeName));
2623
+ if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
2624
+ continue;
2625
+ }
2626
+ // There will be a run time error if a field can return an Interface without any Object implementations.
2627
+ const implementationTypeNames = this.concreteTypeNamesByAbstractTypeName.get(referencedTypeName);
2628
+ if (!implementationTypeNames || implementationTypeNames.size < 0) {
2629
+ // Temporarily propagate as a warning until @inaccessible, entity interfaces and other such considerations are handled
2630
+ this.warnings.push((0, warnings_1.unimplementedInterfaceOutputTypeWarning)(this.subgraphName, referencedTypeName));
2530
2631
  }
2531
2632
  }
2532
2633
  const persistedDirectiveDefinitionDataByDirectiveName = new Map();