Skip to content

Commit f532966

Browse files
authored
[Fusion] Updated source schema validation rule "ExternalOverrideCollisionRule" (#8785)
1 parent ed029a3 commit f532966

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
<value>The interface field '{0}' in schema '{1}' must not be marked as external.</value>
215215
</data>
216216
<data name="LogEntryHelper_ExternalOverrideCollision" xml:space="preserve">
217-
<value>The external field '{0}' must not be annotated with the @override directive.</value>
217+
<value>The external field '{0}' in schema '{1}' must not be annotated with the @override directive.</value>
218218
</data>
219219
<data name="LogEntryHelper_ExternalUnused" xml:space="preserve">
220220
<value>The external field '{0}' in schema '{1}' is not referenced by a @provides directive in the schema.</value>

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaValidationRules/ExternalOverrideCollisionRule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace HotChocolate.Fusion.SourceSchemaValidationRules;
1010
/// schema, and the current schema merely references it. Therefore, a field marked with
1111
/// <c>@external</c> must <b>not</b> simultaneously carry directives that assume local ownership or
1212
/// resolution responsibility, such as <c>@override</c>, which transfers ownership of the field’s
13-
/// definition from one schema to another.
13+
/// definition from one schema to another, and is incompatible with an already-external field
14+
/// definition.
1415
/// </summary>
1516
/// <seealso href="https://graphql.github.io/composite-schemas-spec/draft/#sec-External-Override-Collision">
1617
/// Specification

src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/SourceSchemaValidationRules/ExternalOverrideCollisionRuleTests.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,20 @@ public static TheoryData<string[]> ValidExamplesData()
4848
{
4949
return new TheoryData<string[]>
5050
{
51-
// In this scenario, "User.fullName" is overriding the field from schema A. Since
52-
// @override is not combined with @external on the same field, no collision occurs.
51+
// In this scenario, "User.fullName" is defined in Schema A, but overridden in Schema B.
52+
// Since @override is not combined with @external on the same field, no collision
53+
// occurs.
5354
{
5455
[
5556
"""
57+
# Source Schema A
58+
type User {
59+
id: ID!
60+
fullName: String
61+
}
62+
""",
63+
"""
64+
# Source Schema B
5665
type User {
5766
id: ID!
5867
fullName: String @override(from: "A")
@@ -73,14 +82,23 @@ public static TheoryData<string[], string[]> InvalidExamplesData()
7382
{
7483
[
7584
"""
85+
# Source Schema A
86+
type Payment {
87+
id: ID!
88+
amount: Int
89+
}
90+
""",
91+
"""
92+
# Source Schema B
7693
type Payment {
7794
id: ID!
7895
amount: Int @override(from: "A") @external
7996
}
8097
"""
8198
],
8299
[
83-
"The external field 'Payment.amount' must not be annotated with the @override directive."
100+
"The external field 'Payment.amount' in schema 'B' must not be annotated with "
101+
+ "the @override directive."
84102
]
85103
}
86104
};

0 commit comments

Comments
 (0)