|
6 | 6 | CompositionWarning, |
7 | 7 | GraphPruningIssue, |
8 | 8 | LintIssue, |
| 9 | + LintSeverity, |
9 | 10 | ProposalSubgraph, |
10 | 11 | SchemaChange, |
11 | 12 | VCSContext, |
@@ -744,8 +745,13 @@ export class SchemaCheckRepository { |
744 | 745 | const compositionErrors: PlainMessage<CompositionError>[] = []; |
745 | 746 | const compositionWarnings: PlainMessage<CompositionWarning>[] = []; |
746 | 747 |
|
| 748 | + type ExtendedCheckSubgraph = CheckSubgraph & { |
| 749 | + lintIssues: SchemaLintIssues; |
| 750 | + pruneIssues: SchemaGraphPruningIssues; |
| 751 | + }; |
| 752 | + |
747 | 753 | const federatedGraphs: FederatedGraphDTO[] = []; |
748 | | - const checkSubgraphs: Map<string, CheckSubgraph> = new Map(); |
| 754 | + const checkSubgraphs: Map<string, ExtendedCheckSubgraph> = new Map(); |
749 | 755 | const fedGraphIdToCheckFedGraphId = new Map<string, string>(); |
750 | 756 |
|
751 | 757 | const changeRetention = await orgRepo.getFeature({ |
@@ -943,6 +949,8 @@ export class SchemaCheckRepository { |
943 | 949 | checkSubgraphId: schemaCheckSubgraphId, |
944 | 950 | routerCompatibilityVersion, |
945 | 951 | labels: s.isNew ? s.labels : undefined, |
| 952 | + lintIssues: { warnings: [], errors: [] }, |
| 953 | + pruneIssues: { warnings: [], errors: [] }, |
946 | 954 | }); |
947 | 955 | } |
948 | 956 |
|
@@ -1029,13 +1037,6 @@ export class SchemaCheckRepository { |
1029 | 1037 | storedBreakingChanges, |
1030 | 1038 | ); |
1031 | 1039 |
|
1032 | | - checkSubgraphs.set(subgraphName, { |
1033 | | - ...checkSubgraph, |
1034 | | - inspectorChanges, |
1035 | | - storedBreakingChanges, |
1036 | | - checkSubgraphId: schemaCheckSubgraphId, |
1037 | | - }); |
1038 | | - |
1039 | 1040 | const lintIssues: SchemaLintIssues = await schemaLintRepo.performSchemaLintCheck({ |
1040 | 1041 | schemaCheckID, |
1041 | 1042 | newSchemaSDL, |
@@ -1119,6 +1120,15 @@ export class SchemaCheckRepository { |
1119 | 1120 | }), |
1120 | 1121 | ), |
1121 | 1122 | ); |
| 1123 | + |
| 1124 | + checkSubgraphs.set(subgraphName, { |
| 1125 | + ...checkSubgraph, |
| 1126 | + inspectorChanges, |
| 1127 | + storedBreakingChanges, |
| 1128 | + checkSubgraphId: schemaCheckSubgraphId, |
| 1129 | + lintIssues, |
| 1130 | + pruneIssues: graphPruningIssues, |
| 1131 | + }); |
1122 | 1132 | } |
1123 | 1133 |
|
1124 | 1134 | const { composedGraphs } = await composer.composeWithProposedSchemas({ |
@@ -1322,13 +1332,63 @@ export class SchemaCheckRepository { |
1322 | 1332 | } |
1323 | 1333 | } |
1324 | 1334 |
|
| 1335 | + // Execute the subgraph check extension webhook |
| 1336 | + const sceResult = await webhookService.sendSubgraphCheckExtension({ |
| 1337 | + actorId, |
| 1338 | + schemaCheckID, |
| 1339 | + blobStorage, |
| 1340 | + admissionConfig, |
| 1341 | + organization: { id: organizationId, slug: organizationSlug }, |
| 1342 | + namespace, |
| 1343 | + vcsContext, |
| 1344 | + subgraphs: [...checkSubgraphs.entries()].map(([subgraphName, { subgraph, ...check }]) => ({ |
| 1345 | + id: subgraph?.id ?? '', |
| 1346 | + name: subgraphName, |
| 1347 | + labels: subgraph?.labels ?? check.labels ?? [], |
| 1348 | + schemaSDL: subgraph?.schemaSDL ?? '', |
| 1349 | + schemaChanges: check.schemaChanges, |
| 1350 | + lintIssues: check.lintIssues, |
| 1351 | + pruneIssues: check.pruneIssues, |
| 1352 | + newSchemaSDL: check.newSchemaSDL, |
| 1353 | + isDeleted: check.newSchemaSDL === '', |
| 1354 | + })), |
| 1355 | + affectedGraphs: federatedGraphs, |
| 1356 | + composedGraphs, |
| 1357 | + inspectedOperations, |
| 1358 | + }); |
| 1359 | + |
| 1360 | + if (sceResult?.lintIssuesBySubgraph) { |
| 1361 | + for (const [subgraphName, check] of checkSubgraphs.entries()) { |
| 1362 | + const sceLintIssues = sceResult.lintIssuesBySubgraph.get(subgraphName); |
| 1363 | + if (sceLintIssues && sceLintIssues.length > 0) { |
| 1364 | + const sceLintWarnings = sceLintIssues.filter((issue) => issue.severity === LintSeverity.warn); |
| 1365 | + const sceLintErrors = sceLintIssues.filter((issue) => issue.severity === LintSeverity.error); |
| 1366 | + |
| 1367 | + check.lintIssues.warnings.push(...sceLintIssues.filter((issue) => issue.severity === LintSeverity.warn)); |
| 1368 | + check.lintIssues.errors.push(...sceLintIssues.filter((issue) => issue.severity === LintSeverity.error)); |
| 1369 | + |
| 1370 | + lintWarnings.push(...sceLintWarnings.map((issue) => new LintIssue({ ...issue, subgraphName }))); |
| 1371 | + lintErrors.push(...sceLintErrors.map((issue) => new LintIssue({ ...issue, subgraphName }))); |
| 1372 | + |
| 1373 | + // Then, we need to add the overwritten lint issues |
| 1374 | + await schemaLintRepo.addSchemaCheckLintIssues({ |
| 1375 | + schemaCheckId: schemaCheckID, |
| 1376 | + lintIssues: sceLintIssues, |
| 1377 | + schemaCheckSubgraphId: check.checkSubgraphId, |
| 1378 | + }); |
| 1379 | + } |
| 1380 | + } |
| 1381 | + } |
| 1382 | + |
1325 | 1383 | // Update the overall schema check with the results |
1326 | 1384 | await this.update({ |
1327 | 1385 | schemaCheckID, |
1328 | 1386 | hasClientTraffic, |
1329 | 1387 | hasBreakingChanges: breakingChanges.length > 0 || composedSchemaBreakingChanges.length > 0, |
1330 | 1388 | hasLintErrors: lintErrors.length > 0, |
1331 | 1389 | hasGraphPruningErrors: graphPruneErrors.length > 0, |
| 1390 | + checkExtensionDeliveryId: sceResult?.deliveryInfo?.id, |
| 1391 | + checkExtensionErrorMessage: sceResult?.deliveryInfo?.errorMessage ?? undefined, |
1332 | 1392 | }); |
1333 | 1393 |
|
1334 | 1394 | let isLinkedTrafficCheckFailed = false; |
|
0 commit comments