Skip to content

Commit

Permalink
Fix missing sources computation for composition hints/errors (#3075)
Browse files Browse the repository at this point in the history
This PR fixes the issue identified in [this review
comment](#3069 (comment)).
Specifically, this PR fixes the bug in composition hint/error message
generation where missing sources were computed incorrectly. (No
changeset needed since the referenced PR hasn't been released yet.)
  • Loading branch information
sachindshinde authored Jul 11, 2024
1 parent f560372 commit 2048ae4
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions composition-js/src/merging/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,31 @@ export class MismatchReporter {
) {
const distributionMap = new MultiMap<string, string>();
const astNodes: SubgraphASTNode[] = [];
for (const [i, subgraphElt] of subgraphElements.entries()) {
if (!subgraphElt) {
if (includeMissingSources) {
distributionMap.add('', this.names[i]);
}
continue;
}
const processSubgraphElt = (name: string, subgraphElt: TMismatched) => {
if (ignorePredicate && ignorePredicate(subgraphElt)) {
continue;
return;
}
const elt = mismatchAccessor(subgraphElt, false);
distributionMap.add(elt ?? '', this.names[i]);
distributionMap.add(elt ?? '', name);
if (subgraphElt.sourceAST) {
astNodes.push(addSubgraphToASTNode(subgraphElt.sourceAST, this.names[i]));
astNodes.push(addSubgraphToASTNode(subgraphElt.sourceAST, name));
}
}
if (includeMissingSources) {
for (const [i, name] of this.names.entries()) {
const subgraphElt = subgraphElements.get(i);
if (!subgraphElt) {
distributionMap.add('', name);
continue;
}
processSubgraphElt(name, subgraphElt);
}
} else {
for (const [i, subgraphElt] of subgraphElements.entries()) {
if (!subgraphElt) {
continue;
}
processSubgraphElt(this.names[i], subgraphElt);
}
}
const supergraphMismatch = (supergraphElement && mismatchAccessor(supergraphElement, true)) ?? '';
Expand Down

0 comments on commit 2048ae4

Please sign in to comment.