-
-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fusion] Added pre-merge validation rule "ExternalOnInterfaceRule" (#…
- Loading branch information
1 parent
9a34a3b
commit 1a6811b
Showing
7 changed files
with
170 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...e/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/ExternalOnInterfaceRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using HotChocolate.Fusion.Events; | ||
using HotChocolate.Skimmed; | ||
using static HotChocolate.Fusion.Logging.LogEntryHelper; | ||
|
||
namespace HotChocolate.Fusion.PreMergeValidation.Rules; | ||
|
||
/// <summary> | ||
/// The <c>@external</c> directive indicates that a field is defined and resolved elsewhere, not in | ||
/// the current schema. In the case of an interface type, fields are abstract - they do not have | ||
/// direct resolutions at the interface level. Instead, each implementing object type provides the | ||
/// concrete field implementations. Marking an interface field with <c>@external</c> is therefore | ||
/// nonsensical, as there is no actual field resolution in the interface itself to “borrow” from | ||
/// another schema. Such usage raises an <c>EXTERNAL_ON_INTERFACE</c> error. | ||
/// </summary> | ||
/// <seealso href="https://graphql.github.io/composite-schemas-spec/draft/#sec-External-on-Interface"> | ||
/// Specification | ||
/// </seealso> | ||
internal sealed class ExternalOnInterfaceRule : IEventHandler<OutputFieldEvent> | ||
{ | ||
public void Handle(OutputFieldEvent @event, CompositionContext context) | ||
{ | ||
var (field, type, schema) = @event; | ||
|
||
if (type is InterfaceTypeDefinition && ValidationHelper.IsExternal(field)) | ||
{ | ||
context.Log.Write(ExternalOnInterface(field, type, schema)); | ||
} | ||
} | ||
} |
117 changes: 26 additions & 91 deletions
117
...Chocolate/Fusion-vnext/src/Fusion.Composition/Properties/CompositionResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.