-
-
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.
Refactored Fusion Composition validation (#7821)
- Loading branch information
Showing
19 changed files
with
318 additions
and
281 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Collections/MultiValueDictionary.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,28 @@ | ||
namespace HotChocolate.Fusion.Collections; | ||
|
||
internal sealed class MultiValueDictionary<TKey, TValue> | ||
: Dictionary<TKey, List<TValue>> where TKey : notnull | ||
{ | ||
public void Add(TKey key, TValue value) | ||
{ | ||
ArgumentNullException.ThrowIfNull(key); | ||
|
||
if (!TryGetValue(key, out var list)) | ||
{ | ||
list = []; | ||
Add(key, list); | ||
} | ||
|
||
list.Add(value); | ||
} | ||
|
||
public void Remove(TKey key, TValue value) | ||
{ | ||
ArgumentNullException.ThrowIfNull(key); | ||
|
||
if (TryGetValue(key, out var list)) | ||
{ | ||
list.Remove(value); | ||
} | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Errors/ErrorHelper.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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
using HotChocolate.Fusion.PreMergeValidation.Contracts; | ||
using static HotChocolate.Fusion.Properties.CompositionResources; | ||
|
||
namespace HotChocolate.Fusion.Errors; | ||
|
||
internal static class ErrorHelper | ||
{ | ||
public static CompositionError PreMergeValidationRuleFailed(IPreMergeValidationRule rule) | ||
=> new(string.Format(ErrorHelper_PreMergeValidationRuleFailed, rule.GetType().Name)); | ||
public static CompositionError PreMergeValidationFailed() | ||
=> new(ErrorHelper_PreMergeValidationFailed); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Events/IEvent.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,3 @@ | ||
namespace HotChocolate.Fusion.Events; | ||
|
||
internal interface IEvent; |
6 changes: 6 additions & 0 deletions
6
src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Events/IEventHandler.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,6 @@ | ||
namespace HotChocolate.Fusion.Events; | ||
|
||
internal interface IEventHandler<in TEvent> where TEvent : IEvent | ||
{ | ||
void Handle(TEvent @event, CompositionContext context); | ||
} |
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
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
37 changes: 0 additions & 37 deletions
37
src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LoggingSession.cs
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...sion-vnext/src/Fusion.Composition/PreMergeValidation/Contracts/IPreMergeValidationRule.cs
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Events.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,44 @@ | ||
using System.Collections.Immutable; | ||
using HotChocolate.Fusion.Events; | ||
using HotChocolate.Skimmed; | ||
|
||
namespace HotChocolate.Fusion.PreMergeValidation; | ||
|
||
internal record DirectiveArgumentEvent( | ||
InputFieldDefinition Argument, | ||
DirectiveDefinition Directive, | ||
SchemaDefinition Schema) : IEvent; | ||
|
||
internal record DirectiveEvent( | ||
DirectiveDefinition Directive, | ||
SchemaDefinition Schema) : IEvent; | ||
|
||
internal record FieldArgumentEvent( | ||
InputFieldDefinition Argument, | ||
OutputFieldDefinition Field, | ||
INamedTypeDefinition Type, | ||
SchemaDefinition Schema) : IEvent; | ||
|
||
internal record FieldArgumentGroupEvent( | ||
string ArgumentName, | ||
ImmutableArray<FieldArgumentInfo> ArgumentGroup, | ||
string FieldName, | ||
string TypeName) : IEvent; | ||
|
||
internal record OutputFieldEvent( | ||
OutputFieldDefinition Field, | ||
INamedTypeDefinition Type, | ||
SchemaDefinition Schema) : IEvent; | ||
|
||
internal record OutputFieldGroupEvent( | ||
string FieldName, | ||
ImmutableArray<OutputFieldInfo> FieldGroup, | ||
string TypeName) : IEvent; | ||
|
||
internal record TypeEvent( | ||
INamedTypeDefinition Type, | ||
SchemaDefinition Schema) : IEvent; | ||
|
||
internal record TypeGroupEvent( | ||
string TypeName, | ||
ImmutableArray<TypeInfo> TypeGroup) : IEvent; |
77 changes: 0 additions & 77 deletions
77
...olate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/PreMergeValidationContext.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.