-
-
Notifications
You must be signed in to change notification settings - Fork 749
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 "QueryRootTypeInaccessibleRule"
- Loading branch information
Showing
7 changed files
with
249 additions
and
20 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
27 changes: 27 additions & 0 deletions
27
...on-vnext/src/Fusion.Composition/PreMergeValidation/Rules/QueryRootTypeInaccessibleRule.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,27 @@ | ||
using HotChocolate.Fusion.Events; | ||
using static HotChocolate.Fusion.Logging.LogEntryHelper; | ||
|
||
namespace HotChocolate.Fusion.PreMergeValidation.Rules; | ||
|
||
/// <summary> | ||
/// Every source schema that contributes to the final composite schema must expose a public | ||
/// (accessible) root query type. Marking the root query type as <c>@inaccessible</c> makes it | ||
/// invisible to the gateway, defeating its purpose as the primary entry point for queries and | ||
/// lookups. | ||
/// </summary> | ||
/// <seealso href="https://graphql.github.io/composite-schemas-spec/draft/#sec-Query-Root-Type-Inaccessible"> | ||
/// Specification | ||
/// </seealso> | ||
internal sealed class QueryRootTypeInaccessibleRule : IEventHandler<SchemaEvent> | ||
{ | ||
public void Handle(SchemaEvent @event, CompositionContext context) | ||
{ | ||
var schema = @event.Schema; | ||
var rootQuery = schema.QueryType; | ||
|
||
if (rootQuery is not null && !ValidationHelper.IsAccessible(rootQuery)) | ||
{ | ||
context.Log.Write(QueryRootTypeInaccessible(rootQuery, schema)); | ||
} | ||
} | ||
} |
123 changes: 103 additions & 20 deletions
123
...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.