Skip to content

Commit c395c16

Browse files
authored
[Fusion] Added pre-merge validation rule "InvalidFieldSharingRule" (#8738)
1 parent 4b8c131 commit c395c16

File tree

196 files changed

+1636
-1080
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+1636
-1080
lines changed

src/HotChocolate/AspNetCore/benchmarks/k6/performance-data.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
2-
"timestamp": "2025-10-28T10:35:15Z",
2+
"timestamp": "2025-10-28T10:49:37Z",
33
"tests": {
44
"single-fetch": {
55
"name": "Single Fetch (50 products, names only)",
66
"response_time": {
7-
"min": 1.367661,
8-
"p50": 2.180789,
9-
"max": 41.619313,
10-
"avg": 2.428901219293327,
11-
"p90": 3.533614900000001,
12-
"p95": 4.113232549999999,
13-
"p99": 6.6563870399999745
7+
"min": 1.350863,
8+
"p50": 2.2166075000000003,
9+
"max": 47.099152,
10+
"avg": 2.5468350569105658,
11+
"p90": 3.8372352,
12+
"p95": 4.785266199999996,
13+
"p99": 7.70086295
1414
},
1515
"throughput": {
16-
"requests_per_second": 78.71140999724626,
17-
"total_iterations": 7163
16+
"requests_per_second": 78.75998155086224,
17+
"total_iterations": 7165
1818
},
1919
"reliability": {
2020
"error_rate": 0
@@ -23,17 +23,17 @@
2323
"dataloader": {
2424
"name": "DataLoader (50 products with brands)",
2525
"response_time": {
26-
"min": 2.652555,
27-
"p50": 4.058844000000001,
28-
"max": 19.402633,
29-
"avg": 4.470873844347582,
30-
"p90": 6.1823778,
31-
"p95": 7.565768349999999,
32-
"p99": 11.076760349999999
26+
"min": 2.633183,
27+
"p50": 3.997002,
28+
"max": 18.020958,
29+
"avg": 4.356490303162331,
30+
"p90": 5.9975004,
31+
"p95": 7.313034499999997,
32+
"p99": 11.124407259999987
3333
},
3434
"throughput": {
35-
"requests_per_second": 78.4977656947644,
36-
"total_iterations": 7143
35+
"requests_per_second": 78.52036814348355,
36+
"total_iterations": 7146
3737
},
3838
"reliability": {
3939
"error_rate": 0

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Events/GroupEvents.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ internal record InputTypeGroupEvent(
2323
string InputTypeName,
2424
ImmutableArray<InputTypeInfo> InputTypeGroup) : IEvent;
2525

26+
internal record ObjectFieldGroupEvent(
27+
string FieldName,
28+
ImmutableArray<ObjectFieldInfo> FieldGroup,
29+
string TypeName) : IEvent;
30+
2631
internal record OutputFieldGroupEvent(
2732
string FieldName,
2833
ImmutableArray<OutputFieldInfo> FieldGroup,

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Extensions/MutableComplexTypeDefinitionExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ public static void ApplyKeyDirective(this MutableComplexTypeDefinition type, str
2424
new ArgumentAssignment(ArgumentNames.Fields, keyFields)));
2525
}
2626
}
27+
28+
public static IEnumerable<Directive> GetKeyDirectives(this MutableComplexTypeDefinition type)
29+
{
30+
return type.Directives.AsEnumerable().Where(d => d.Name == DirectiveNames.Key);
31+
}
2732
}

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Extensions/MutableOutputFieldDefinitionExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ public static string GetKeyFields(
9696
return mergedSelectionSet.ToString(indented: false).AsSpan()[2..^2].ToString();
9797
}
9898

99+
public static string? GetOverrideFrom(this MutableOutputFieldDefinition field)
100+
{
101+
var overrideDirective =
102+
field.Directives.AsEnumerable().SingleOrDefault(d => d.Name == DirectiveNames.Override);
103+
104+
return (string?)overrideDirective?.Arguments[ArgumentNames.From].Value;
105+
}
106+
99107
public static bool HasInternalDirective(this MutableOutputFieldDefinition field)
100108
{
101109
return field.Directives.ContainsName(DirectiveNames.Internal);

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Extensions/OutputFieldDefinitionExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Immutable;
2+
using HotChocolate.Features;
23
using HotChocolate.Fusion.Features;
34
using HotChocolate.Types;
45
using static HotChocolate.Fusion.WellKnownArgumentNames;
@@ -26,8 +27,9 @@ public static ImmutableArray<string> GetSchemaNames(
2627
return [.. schemaNames];
2728
}
2829

29-
public static SourceFieldMetadata? GetSourceFieldMetadata(this IOutputFieldDefinition field)
30+
public static SourceFieldMetadata GetRequiredSourceFieldMetadata(
31+
this IOutputFieldDefinition field)
3032
{
31-
return field.Features.Get<SourceFieldMetadata>();
33+
return field.Features.GetRequired<SourceFieldMetadata>();
3234
}
3335
}

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Extensions/OutputFieldInfoExtensions.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Features/SourceFieldMetadata.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ namespace HotChocolate.Fusion.Features;
22

33
internal sealed class SourceFieldMetadata
44
{
5+
public bool HasShareableDirective { get; set; }
6+
7+
public bool IsExternal { get; set; }
8+
9+
public bool IsInternal { get; set; }
10+
511
public bool IsKeyField { get; set; }
612

13+
public bool IsOverridden { get; set; }
14+
715
public bool IsShareable { get; set; }
816
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using HotChocolate.Types.Mutable;
2+
3+
namespace HotChocolate.Fusion.Info;
4+
5+
internal record ObjectFieldInfo(
6+
MutableOutputFieldDefinition Field,
7+
MutableObjectTypeDefinition Type,
8+
MutableSchemaDefinition Schema);

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryCodes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static class LogEntryCodes
2828
public const string InputFieldTypesNotMergeable = "INPUT_FIELD_TYPES_NOT_MERGEABLE";
2929
public const string InputWithMissingRequiredFields = "INPUT_WITH_MISSING_REQUIRED_FIELDS";
3030
public const string InterfaceFieldNoImplementation = "INTERFACE_FIELD_NO_IMPLEMENTATION";
31+
public const string InvalidFieldSharing = "INVALID_FIELD_SHARING";
3132
public const string InvalidGraphQL = "INVALID_GRAPHQL";
3233
public const string InvalidShareableUsage = "INVALID_SHAREABLE_USAGE";
3334
public const string IsInvalidFields = "IS_INVALID_FIELDS";

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/Logging/LogEntryHelper.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,22 @@ public static LogEntry InterfaceFieldNoImplementation(
502502
.Build();
503503
}
504504

505+
public static LogEntry InvalidFieldSharing(
506+
MutableOutputFieldDefinition field,
507+
MutableSchemaDefinition schema)
508+
{
509+
return LogEntryBuilder.New()
510+
.SetMessage(
511+
LogEntryHelper_InvalidFieldSharing,
512+
field.Coordinate.ToString(),
513+
schema.Name)
514+
.SetCode(LogEntryCodes.InvalidFieldSharing)
515+
.SetSeverity(LogSeverity.Error)
516+
.SetTypeSystemMember(field)
517+
.SetSchema(schema)
518+
.Build();
519+
}
520+
505521
public static LogEntry InvalidGraphQL(string exceptionMessage, MutableSchemaDefinition schema)
506522
{
507523
return LogEntryBuilder.New()

0 commit comments

Comments
 (0)