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