@wundergraph/composition 0.37.2 → 0.38.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 (34) hide show
  1. package/dist/errors/errors.d.ts +2 -2
  2. package/dist/errors/errors.js +6 -4
  3. package/dist/errors/errors.js.map +1 -1
  4. package/dist/federation/types.d.ts +10 -2
  5. package/dist/normalization/types.d.ts +1 -0
  6. package/dist/schema-building/types.d.ts +18 -14
  7. package/dist/schema-building/utils.d.ts +6 -4
  8. package/dist/schema-building/utils.js +39 -48
  9. package/dist/schema-building/utils.js.map +1 -1
  10. package/dist/subgraph/types.d.ts +1 -0
  11. package/dist/tsconfig.tsbuildinfo +1 -1
  12. package/dist/utils/composition-version.js +1 -1
  13. package/dist/utils/string-constants.d.ts +1 -0
  14. package/dist/utils/string-constants.js +2 -0
  15. package/dist/utils/string-constants.js.map +1 -1
  16. package/dist/utils/utils.d.ts +6 -1
  17. package/dist/utils/utils.js +38 -0
  18. package/dist/utils/utils.js.map +1 -1
  19. package/dist/v1/federation/federation-factory.d.ts +24 -13
  20. package/dist/v1/federation/federation-factory.js +435 -347
  21. package/dist/v1/federation/federation-factory.js.map +1 -1
  22. package/dist/v1/normalization/normalization-factory.d.ts +6 -6
  23. package/dist/v1/normalization/normalization-factory.js +66 -52
  24. package/dist/v1/normalization/normalization-factory.js.map +1 -1
  25. package/dist/v1/normalization/utils.d.ts +1 -1
  26. package/dist/v1/normalization/utils.js +3 -1
  27. package/dist/v1/normalization/utils.js.map +1 -1
  28. package/dist/v1/normalization/walkers.js +17 -24
  29. package/dist/v1/normalization/walkers.js.map +1 -1
  30. package/dist/v1/schema-building/type-merging.d.ts +1 -1
  31. package/dist/v1/utils/utils.d.ts +0 -2
  32. package/dist/v1/utils/utils.js +0 -12
  33. package/dist/v1/utils/utils.js.map +1 -1
  34. package/package.json +2 -2
@@ -41,7 +41,6 @@ function normalizeSubgraph(document, subgraphName, internalGraph) {
41
41
  class NormalizationFactory {
42
42
  argumentName = '';
43
43
  authorizationDataByParentTypeName = new Map();
44
- childName = '';
45
44
  concreteTypeNamesByAbstractTypeName = new Map();
46
45
  conditionalFieldDataByCoords = new Map();
47
46
  configurationDataByTypeName = new Map();
@@ -70,6 +69,7 @@ class NormalizationFactory {
70
69
  lastChildNodeKind = graphql_1.Kind.NULL;
71
70
  leafTypeNamesWithAuthorizationDirectives = new Set();
72
71
  keyFieldSetDataByTypeName = new Map();
72
+ keyFieldSetsByEntityTypeNameByFieldCoords = new Map();
73
73
  keyFieldNamesByParentTypeName = new Map();
74
74
  operationTypeNodeByTypeName = new Map();
75
75
  originalParentTypeName = '';
@@ -100,13 +100,12 @@ class NormalizationFactory {
100
100
  operationTypes: new Map(),
101
101
  };
102
102
  }
103
- validateInputNamedType(namedType) {
104
- if (constants_1.BASE_SCALARS.has(namedType)) {
103
+ validateInputNamedType(namedTypeName) {
104
+ if (constants_1.BASE_SCALARS.has(namedTypeName)) {
105
105
  return { hasUnhandledError: false, typeString: '' };
106
106
  }
107
- const parentData = this.parentDefinitionDataByTypeName.get(namedType);
107
+ const parentData = this.parentDefinitionDataByTypeName.get(namedTypeName);
108
108
  if (!parentData) {
109
- this.errors.push((0, errors_1.undefinedTypeError)(namedType));
110
109
  return { hasUnhandledError: false, typeString: '' };
111
110
  }
112
111
  switch (parentData.kind) {
@@ -122,6 +121,9 @@ class NormalizationFactory {
122
121
  const invalidArguments = [];
123
122
  for (const [argumentName, argumentNode] of fieldData.argumentDataByArgumentName) {
124
123
  const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentNode.type);
124
+ if (!constants_1.BASE_SCALARS.has(namedTypeName)) {
125
+ this.referencedTypeNames.add(namedTypeName);
126
+ }
125
127
  const { hasUnhandledError, typeString } = this.validateInputNamedType(namedTypeName);
126
128
  if (hasUnhandledError) {
127
129
  invalidArguments.push({
@@ -184,6 +186,7 @@ class NormalizationFactory {
184
186
  return;
185
187
  }
186
188
  const scopesArgument = directiveNode.arguments[0];
189
+ // @TODO list coercion
187
190
  if (scopesArgument.name.value !== string_constants_2.SCOPES || scopesArgument.value.kind !== graphql_1.Kind.LIST) {
188
191
  return;
189
192
  }
@@ -728,6 +731,7 @@ class NormalizationFactory {
728
731
  }
729
732
  addFieldDataByNode(fieldDataByFieldName, node, argumentDataByArgumentName, directivesByDirectiveName) {
730
733
  const name = node.name.value;
734
+ const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
731
735
  const fieldCoords = `${this.originalParentTypeName}.${name}`;
732
736
  const { isExternal, isShareable } = (0, utils_4.isNodeExternalOrShareable)(node, !this.isSubgraphVersionTwo, directivesByDirectiveName);
733
737
  const fieldData = {
@@ -736,6 +740,7 @@ class NormalizationFactory {
736
740
  externalFieldDataBySubgraphName: new Map([
737
741
  [this.subgraphName, (0, utils_4.newExternalFieldData)(isExternal)],
738
742
  ]),
743
+ federatedCoords: `${parentTypeName}.${name}`,
739
744
  isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
740
745
  isShareableBySubgraphName: new Map([[this.subgraphName, isShareable]]),
741
746
  kind: graphql_1.Kind.FIELD_DEFINITION,
@@ -744,12 +749,15 @@ class NormalizationFactory {
744
749
  node: (0, ast_1.getMutableFieldNode)(node, fieldCoords, this.errors),
745
750
  originalParentTypeName: this.originalParentTypeName,
746
751
  persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
747
- renamedParentTypeName: this.renamedParentTypeName || this.originalParentTypeName,
752
+ renamedParentTypeName: parentTypeName,
748
753
  subgraphNames: new Set([this.subgraphName]),
749
754
  type: (0, ast_1.getMutableTypeNode)(node.type, fieldCoords, this.errors),
750
755
  directivesByDirectiveName,
751
756
  description: (0, utils_1.formatDescription)(node.description),
752
757
  };
758
+ if (!constants_1.BASE_SCALARS.has(fieldData.namedTypeName)) {
759
+ this.referencedTypeNames.add(fieldData.namedTypeName);
760
+ }
753
761
  this.extractConfigureDescriptionsData(fieldData);
754
762
  fieldDataByFieldName.set(name, fieldData);
755
763
  return fieldData;
@@ -768,10 +776,11 @@ class NormalizationFactory {
768
776
  isArgument,
769
777
  kind: isArgument ? graphql_1.Kind.ARGUMENT : graphql_1.Kind.INPUT_VALUE_DEFINITION,
770
778
  name,
779
+ namedTypeName: (0, ast_1.getTypeNodeNamedTypeName)(node.type),
771
780
  node: (0, ast_1.getMutableInputValueNode)(node, originalPath, this.errors),
772
- originalPath,
781
+ originalCoords: originalPath,
773
782
  persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
774
- renamedPath: renamedPath || originalPath,
783
+ federatedCoords: renamedPath || originalPath,
775
784
  requiredSubgraphNames: new Set((0, utils_4.isTypeRequired)(node.type) ? [this.subgraphName] : []),
776
785
  subgraphNames: new Set([this.subgraphName]),
777
786
  type: (0, ast_1.getMutableTypeNode)(node.type, originalPath, this.errors),
@@ -892,6 +901,7 @@ class NormalizationFactory {
892
901
  return;
893
902
  }
894
903
  this.setParentDataExtensionType(parentData, extensionType);
904
+ parentData.isInaccessible ||= directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
895
905
  parentData.subgraphNames.add(this.subgraphName);
896
906
  parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
897
907
  this.extractConfigureDescriptionsData(parentData);
@@ -903,6 +913,7 @@ class NormalizationFactory {
903
913
  directivesByDirectiveName,
904
914
  extensionType,
905
915
  enumValueDataByValueName: new Map(),
916
+ isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
906
917
  kind: graphql_1.Kind.ENUM_TYPE_DEFINITION,
907
918
  name: typeName,
908
919
  node: (0, ast_1.getMutableEnumNode)(node.name),
@@ -1402,10 +1413,13 @@ class NormalizationFactory {
1402
1413
  const implementationErrorsMap = new Map();
1403
1414
  const invalidImplementationTypeStringByTypeName = new Map();
1404
1415
  let doesInterfaceImplementItself = false;
1405
- for (const interfaceName of data.implementedInterfaceTypeNames) {
1406
- const interfaceData = this.parentDefinitionDataByTypeName.get(interfaceName);
1416
+ for (const interfaceTypeName of data.implementedInterfaceTypeNames) {
1417
+ const interfaceData = this.parentDefinitionDataByTypeName.get(interfaceTypeName);
1418
+ // This check is so undefined type errors are not improperly propagated
1419
+ if (constants_1.BASE_SCALARS.has(interfaceTypeName)) {
1420
+ this.referencedTypeNames.add(interfaceTypeName);
1421
+ }
1407
1422
  if (!interfaceData) {
1408
- this.errors.push((0, errors_1.undefinedTypeError)(interfaceName));
1409
1423
  continue;
1410
1424
  }
1411
1425
  if (interfaceData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
@@ -1485,7 +1499,7 @@ class NormalizationFactory {
1485
1499
  }
1486
1500
  }
1487
1501
  if (hasErrors) {
1488
- implementationErrorsMap.set(interfaceName, implementationErrors);
1502
+ implementationErrorsMap.set(interfaceTypeName, implementationErrors);
1489
1503
  }
1490
1504
  }
1491
1505
  if (invalidImplementationTypeStringByTypeName.size > 0) {
@@ -1516,7 +1530,7 @@ class NormalizationFactory {
1516
1530
  return;
1517
1531
  }
1518
1532
  const overrideDataForSubgraph = (0, utils_5.getValueOrDefault)(this.overridesByTargetSubgraphName, targetSubgraphName, () => new Map());
1519
- (0, utils_5.getValueOrDefault)(overrideDataForSubgraph, data.renamedParentTypeName || data.originalParentTypeName, () => new Set()).add(data.name);
1533
+ (0, utils_5.getValueOrDefault)(overrideDataForSubgraph, data.renamedParentTypeName, () => new Set()).add(data.name);
1520
1534
  }
1521
1535
  handleRequiresScopesDirective({ directiveCoords, orScopes, requiredScopes }) {
1522
1536
  if (orScopes.length > utils_3.maxOrScopes) {
@@ -1533,7 +1547,7 @@ class NormalizationFactory {
1533
1547
  }
1534
1548
  }
1535
1549
  }
1536
- getKafkaPublishConfiguration(directive, argumentDataByArgumentName, errorMessages) {
1550
+ getKafkaPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
1537
1551
  const topics = [];
1538
1552
  let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
1539
1553
  for (const argumentNode of directive.arguments || []) {
@@ -1560,14 +1574,15 @@ class NormalizationFactory {
1560
1574
  if (errorMessages.length > 0) {
1561
1575
  return;
1562
1576
  }
1563
- return { fieldName: this.childName, providerId, providerType: string_constants_2.PROVIDER_TYPE_KAFKA, topics, type: string_constants_2.PUBLISH };
1577
+ return { fieldName, providerId, providerType: string_constants_2.PROVIDER_TYPE_KAFKA, topics, type: string_constants_2.PUBLISH };
1564
1578
  }
1565
- getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages) {
1579
+ getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
1566
1580
  const topics = [];
1567
1581
  let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
1568
1582
  for (const argumentNode of directive.arguments || []) {
1569
1583
  switch (argumentNode.name.value) {
1570
1584
  case string_constants_2.TOPICS: {
1585
+ //@TODO list coercion
1571
1586
  if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
1572
1587
  errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_2.TOPICS));
1573
1588
  continue;
@@ -1596,14 +1611,14 @@ class NormalizationFactory {
1596
1611
  return;
1597
1612
  }
1598
1613
  return {
1599
- fieldName: this.childName,
1614
+ fieldName,
1600
1615
  providerId,
1601
1616
  providerType: string_constants_2.PROVIDER_TYPE_KAFKA,
1602
1617
  topics: topics,
1603
1618
  type: string_constants_2.SUBSCRIBE,
1604
1619
  };
1605
1620
  }
1606
- getNatsPublishAndRequestConfiguration(eventType, directive, argumentDataByArgumentName, errorMessages) {
1621
+ getNatsPublishAndRequestConfiguration(eventType, directive, argumentDataByArgumentName, fieldName, errorMessages) {
1607
1622
  const subjects = [];
1608
1623
  let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
1609
1624
  for (const argumentNode of directive.arguments || []) {
@@ -1630,9 +1645,9 @@ class NormalizationFactory {
1630
1645
  if (errorMessages.length > 0) {
1631
1646
  return;
1632
1647
  }
1633
- return { fieldName: this.childName, providerId, providerType: string_constants_2.PROVIDER_TYPE_NATS, subjects, type: eventType };
1648
+ return { fieldName, providerId, providerType: string_constants_2.PROVIDER_TYPE_NATS, subjects, type: eventType };
1634
1649
  }
1635
- getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages) {
1650
+ getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
1636
1651
  const subjects = [];
1637
1652
  let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
1638
1653
  let consumerInactiveThreshold = integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
@@ -1641,8 +1656,9 @@ class NormalizationFactory {
1641
1656
  for (const argumentNode of directive.arguments || []) {
1642
1657
  switch (argumentNode.name.value) {
1643
1658
  case string_constants_2.SUBJECTS: {
1659
+ // @TODO list coercion
1644
1660
  if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
1645
- // errorMessages.push(invalidEventSubjectsErrorMessage(SUBJECTS));
1661
+ errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_2.SUBJECTS));
1646
1662
  continue;
1647
1663
  }
1648
1664
  for (const value of argumentNode.value.values) {
@@ -1745,7 +1761,7 @@ class NormalizationFactory {
1745
1761
  this.warnings.push((0, warnings_1.consumerInactiveThresholdInvalidValueWarning)(this.subgraphName, 'The value has been set to 0. This means the consumer will remain indefinitely active until its manual deletion.'));
1746
1762
  }
1747
1763
  return {
1748
- fieldName: this.childName,
1764
+ fieldName,
1749
1765
  providerId,
1750
1766
  providerType: string_constants_2.PROVIDER_TYPE_NATS,
1751
1767
  subjects,
@@ -1766,14 +1782,14 @@ class NormalizationFactory {
1766
1782
  return;
1767
1783
  }
1768
1784
  const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
1769
- const fieldPath = `${parentTypeName}.${node.name.value}`;
1785
+ const fieldCoords = `${parentTypeName}.${node.name.value}`;
1770
1786
  const isSubscription = this.getOperationTypeNodeForRootTypeName(parentTypeName) === graphql_1.OperationTypeNode.SUBSCRIPTION;
1771
1787
  for (const directiveNode of node.directives) {
1772
1788
  if (directiveNode.name.value !== string_constants_2.SUBSCRIPTION_FILTER) {
1773
1789
  continue;
1774
1790
  }
1775
1791
  if (!isSubscription) {
1776
- this.errors.push((0, errors_1.invalidSubscriptionFilterLocationError)(fieldPath));
1792
+ this.errors.push((0, errors_1.invalidSubscriptionFilterLocationError)(fieldCoords));
1777
1793
  return;
1778
1794
  }
1779
1795
  }
@@ -1783,34 +1799,35 @@ class NormalizationFactory {
1783
1799
  if (!node.directives) {
1784
1800
  return;
1785
1801
  }
1786
- const fieldPath = `${this.renamedParentTypeName || this.originalParentTypeName}.${this.childName}`;
1802
+ const fieldName = node.name.value;
1803
+ const fieldCoords = `${this.renamedParentTypeName || this.originalParentTypeName}.${fieldName}`;
1787
1804
  for (const directive of node.directives) {
1788
1805
  const errorMessages = [];
1789
1806
  let eventConfiguration;
1790
1807
  switch (directive.name.value) {
1791
1808
  case string_constants_2.EDFS_KAFKA_PUBLISH:
1792
- eventConfiguration = this.getKafkaPublishConfiguration(directive, argumentDataByArgumentName, errorMessages);
1809
+ eventConfiguration = this.getKafkaPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
1793
1810
  break;
1794
1811
  case string_constants_2.EDFS_KAFKA_SUBSCRIBE:
1795
- eventConfiguration = this.getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages);
1812
+ eventConfiguration = this.getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
1796
1813
  break;
1797
1814
  case string_constants_2.EDFS_NATS_PUBLISH: {
1798
- eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.PUBLISH, directive, argumentDataByArgumentName, errorMessages);
1815
+ eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.PUBLISH, directive, argumentDataByArgumentName, fieldName, errorMessages);
1799
1816
  break;
1800
1817
  }
1801
1818
  case string_constants_2.EDFS_NATS_REQUEST: {
1802
- eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.REQUEST, directive, argumentDataByArgumentName, errorMessages);
1819
+ eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.REQUEST, directive, argumentDataByArgumentName, fieldName, errorMessages);
1803
1820
  break;
1804
1821
  }
1805
1822
  case string_constants_2.EDFS_NATS_SUBSCRIBE: {
1806
- eventConfiguration = this.getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages);
1823
+ eventConfiguration = this.getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
1807
1824
  break;
1808
1825
  }
1809
1826
  default:
1810
1827
  continue;
1811
1828
  }
1812
1829
  if (errorMessages.length > 0) {
1813
- this.errors.push((0, errors_1.invalidEventDirectiveError)(directive.name.value, fieldPath, errorMessages));
1830
+ this.errors.push((0, errors_1.invalidEventDirectiveError)(directive.name.value, fieldCoords, errorMessages));
1814
1831
  continue;
1815
1832
  }
1816
1833
  // should never happen
@@ -1855,7 +1872,7 @@ class NormalizationFactory {
1855
1872
  }
1856
1873
  const validEventDirectiveNames = this.getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode);
1857
1874
  for (const [fieldName, fieldData] of data.fieldDataByFieldName) {
1858
- const fieldPath = `${fieldData.originalParentTypeName}.${fieldName}`;
1875
+ const fieldCoords = `${fieldData.originalParentTypeName}.${fieldName}`;
1859
1876
  const definedEventsDirectiveNames = new Set();
1860
1877
  for (const eventsDirectiveName of string_constants_1.EVENT_DIRECTIVE_NAMES) {
1861
1878
  if (fieldData.directivesByDirectiveName.has(eventsDirectiveName)) {
@@ -1869,7 +1886,7 @@ class NormalizationFactory {
1869
1886
  }
1870
1887
  }
1871
1888
  if (definedEventsDirectiveNames.size < 1 || invalidEventsDirectiveNames.size > 0) {
1872
- invalidEventsDirectiveDataByRootFieldPath.set(fieldPath, {
1889
+ invalidEventsDirectiveDataByRootFieldPath.set(fieldCoords, {
1873
1890
  definesDirectives: definedEventsDirectiveNames.size > 0,
1874
1891
  invalidDirectiveNames: [...invalidEventsDirectiveNames],
1875
1892
  });
@@ -1877,7 +1894,7 @@ class NormalizationFactory {
1877
1894
  if (operationTypeNode === graphql_1.OperationTypeNode.MUTATION) {
1878
1895
  const typeString = (0, merge_1.printTypeNode)(fieldData.type);
1879
1896
  if (typeString !== string_constants_2.NON_NULLABLE_EDFS_PUBLISH_EVENT_RESULT) {
1880
- invalidResponseTypeNameByMutationPath.set(fieldPath, typeString);
1897
+ invalidResponseTypeNameByMutationPath.set(fieldCoords, typeString);
1881
1898
  }
1882
1899
  continue;
1883
1900
  }
@@ -1893,7 +1910,7 @@ class NormalizationFactory {
1893
1910
  }
1894
1911
  }
1895
1912
  if (!isValid || fieldTypeString !== expectedTypeString) {
1896
- invalidResponseTypeStringByRootFieldPath.set(fieldPath, fieldTypeString);
1913
+ invalidResponseTypeStringByRootFieldPath.set(fieldCoords, fieldTypeString);
1897
1914
  }
1898
1915
  }
1899
1916
  }
@@ -1911,14 +1928,14 @@ class NormalizationFactory {
1911
1928
  }
1912
1929
  validateEventDrivenObjectFields(fieldDataByFieldName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath) {
1913
1930
  for (const [fieldName, fieldData] of fieldDataByFieldName) {
1914
- const fieldPath = `${fieldData.originalParentTypeName}.${fieldName}`;
1931
+ const fieldCoords = `${fieldData.originalParentTypeName}.${fieldName}`;
1915
1932
  if (keyFieldNames.has(fieldName)) {
1916
1933
  if (!fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
1917
- nonExternalKeyFieldNameByFieldPath.set(fieldPath, fieldName);
1934
+ nonExternalKeyFieldNameByFieldPath.set(fieldCoords, fieldName);
1918
1935
  }
1919
1936
  continue;
1920
1937
  }
1921
- nonKeyFieldNameByFieldPath.set(fieldPath, fieldName);
1938
+ nonKeyFieldNameByFieldPath.set(fieldCoords, fieldName);
1922
1939
  }
1923
1940
  }
1924
1941
  isEdfsPublishResultValid() {
@@ -2098,7 +2115,7 @@ class NormalizationFactory {
2098
2115
  }
2099
2116
  const typeName = (0, utils_4.getParentTypeName)(parentData);
2100
2117
  const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, typeName, () => (0, utils_6.newConfigurationData)(true, typeName));
2101
- const keys = (0, utils_2.validateKeyFieldSets)(this, parentData, keyFieldSetDataByFieldSet, configurationData.fieldNames);
2118
+ const keys = (0, utils_2.validateKeyFieldSets)(this, parentData, keyFieldSetDataByFieldSet);
2102
2119
  if (keys) {
2103
2120
  configurationData.keys = keys;
2104
2121
  }
@@ -2548,6 +2565,10 @@ class NormalizationFactory {
2548
2565
  const defaultTypeName = (0, utils_5.getOrThrowError)(utils_1.operationTypeNodeToDefaultType, operationType, string_constants_2.OPERATION_TO_DEFAULT);
2549
2566
  // If an operation type name was not declared, use the default
2550
2567
  const operationTypeName = operationTypeNode ? (0, ast_1.getTypeNodeNamedTypeName)(operationTypeNode.type) : defaultTypeName;
2568
+ // This check is so undefined type errors are not improperly propagated
2569
+ if (constants_1.BASE_SCALARS.has(operationTypeName)) {
2570
+ this.referencedTypeNames.add(operationTypeName);
2571
+ }
2551
2572
  // If a custom type is used, the default type should not be defined
2552
2573
  if (operationTypeName !== defaultTypeName && this.parentDefinitionDataByTypeName.has(defaultTypeName)) {
2553
2574
  this.errors.push((0, errors_1.invalidRootTypeDefinitionError)(operationType, operationTypeName, defaultTypeName));
@@ -2556,9 +2577,8 @@ class NormalizationFactory {
2556
2577
  const objectData = this.parentDefinitionDataByTypeName.get(operationTypeName);
2557
2578
  // operationTypeNode is truthy if an operation type was explicitly declared
2558
2579
  if (operationTypeNode) {
2559
- // If the type is not defined in the schema, it's always an error
2580
+ // If the type is not defined in the schema, it will be handled when checking references
2560
2581
  if (!objectData) {
2561
- this.errors.push((0, errors_1.undefinedTypeError)(operationTypeName));
2562
2582
  continue;
2563
2583
  }
2564
2584
  // Add the explicitly defined type to the map for the federation-factory
@@ -2574,13 +2594,6 @@ class NormalizationFactory {
2574
2594
  }
2575
2595
  if (objectData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
2576
2596
  this.errors.push((0, errors_1.operationDefinitionError)(operationTypeName, operationType, objectData.kind));
2577
- continue;
2578
- }
2579
- for (const fieldData of objectData.fieldDataByFieldName.values()) {
2580
- const fieldTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
2581
- if (!constants_1.BASE_SCALARS.has(fieldTypeName) && !this.parentDefinitionDataByTypeName.has(fieldTypeName)) {
2582
- this.errors.push((0, errors_1.undefinedTypeError)(fieldTypeName));
2583
- }
2584
2597
  }
2585
2598
  }
2586
2599
  for (const referencedTypeName of this.referencedTypeNames) {
@@ -2641,6 +2654,7 @@ class NormalizationFactory {
2641
2654
  isEventDrivenGraph: this.isSubgraphEventDrivenGraph,
2642
2655
  isVersionTwo: this.isSubgraphVersionTwo,
2643
2656
  keyFieldNamesByParentTypeName: this.keyFieldNamesByParentTypeName,
2657
+ keyFieldSetsByEntityTypeNameByKeyFieldCoords: this.keyFieldSetsByEntityTypeNameByFieldCoords,
2644
2658
  operationTypes: this.operationTypeNodeByTypeName,
2645
2659
  originalTypeNameByRenamedTypeName: this.originalTypeNameByRenamedTypeName,
2646
2660
  overridesByTargetSubgraphName: this.overridesByTargetSubgraphName,
@@ -2754,14 +2768,14 @@ function batchNormalize(subgraphs) {
2754
2768
  (0, utils_5.addIterableValuesToSet)(fieldNames, existingFieldNames);
2755
2769
  }
2756
2770
  for (const fieldName of fieldNames) {
2757
- const fieldPath = `${originalParentTypeName}.${fieldName}`;
2758
- const sourceSubgraphs = overrideSourceSubgraphNamesByFieldPath.get(fieldPath);
2771
+ const fieldCoords = `${originalParentTypeName}.${fieldName}`;
2772
+ const sourceSubgraphs = overrideSourceSubgraphNamesByFieldPath.get(fieldCoords);
2759
2773
  if (!sourceSubgraphs) {
2760
- overrideSourceSubgraphNamesByFieldPath.set(fieldPath, [subgraphName]);
2774
+ overrideSourceSubgraphNamesByFieldPath.set(fieldCoords, [subgraphName]);
2761
2775
  continue;
2762
2776
  }
2763
2777
  sourceSubgraphs.push(subgraphName);
2764
- duplicateOverriddenFieldPaths.add(fieldPath);
2778
+ duplicateOverriddenFieldPaths.add(fieldCoords);
2765
2779
  }
2766
2780
  }
2767
2781
  }