Skip to content

Commit

Permalink
Fix message for when override conflicts with other directives (#2943)
Browse files Browse the repository at this point in the history
When working with the override directive i received this error (names
changed):
`@override cannot be used on field "myType.myField" on subgraph
"mySubgraph" since "myType.myField" on "mySubgraph" is marked with
directive "@requires"`
But requires was used on "myOtherSubgraph".

I changed the error message to state the correct subgraph and changed
the tests to match the expected behavior.
  • Loading branch information
lukassailer authored Mar 20, 2024
1 parent c38628c commit b4185fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composition-js/src/__tests__/override.compose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ describe("composition involving @override directive", () => {
expect(result.errors).toBeDefined();
expect(errors(result)).toContainEqual([
"OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE",
`@override cannot be used on field "T.u" on subgraph "Subgraph1" since "T.u" on "Subgraph1" is marked with directive "@provides"`,
`@override cannot be used on field "T.u" on subgraph "Subgraph1" since "T.u" on "Subgraph2" is marked with directive "@provides"`,
]);
});

Expand Down Expand Up @@ -718,7 +718,7 @@ describe("composition involving @override directive", () => {
expect(result.errors).toBeDefined();
expect(errors(result)).toContainEqual([
"OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE",
`@override cannot be used on field "T.u" on subgraph "Subgraph1" since "T.u" on "Subgraph1" is marked with directive "@requires"`,
`@override cannot be used on field "T.u" on subgraph "Subgraph1" since "T.u" on "Subgraph2" is marked with directive "@requires"`,
]);
});

Expand Down
2 changes: 1 addition & 1 deletion composition-js/src/merging/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ class Merger {
return {
result: true,
conflictingDirective: directive,
subgraph: subgraphName,
subgraph: this.names[fromIdx],
};
}
}
Expand Down

0 comments on commit b4185fe

Please sign in to comment.