Skip to content

Commit a87b0c7

Browse files
authored
[Fusion] Added and used additional source schema metadata (#8858)
1 parent 7d923e6 commit a87b0c7

File tree

61 files changed

+756
-688
lines changed

Some content is hidden

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

61 files changed

+756
-688
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-30T09:57:56Z",
2+
"timestamp": "2025-10-30T14:07:54Z",
33
"tests": {
44
"single-fetch": {
55
"name": "Single Fetch (50 products, names only)",
66
"response_time": {
7-
"min": 1.323831,
8-
"p50": 1.925301,
9-
"max": 2914.41967,
10-
"avg": 4.320953193351728,
11-
"p90": 3.0773536,
12-
"p95": 3.7324009999999923,
13-
"p99": 6.347429599999995
7+
"min": 1.436582,
8+
"p50": 2.2611749999999997,
9+
"max": 46.726227,
10+
"avg": 2.4997752158676687,
11+
"p90": 3.5180936999999997,
12+
"p95": 4.121452599999998,
13+
"p99": 6.741091230000001
1414
},
1515
"throughput": {
16-
"requests_per_second": 76.04134966987401,
17-
"total_iterations": 6920
16+
"requests_per_second": 78.74785401762489,
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.635789,
27-
"p50": 3.715222,
28-
"max": 29.402523,
29-
"avg": 4.1063235004213325,
30-
"p90": 5.480159600000002,
31-
"p95": 6.8044154999999815,
32-
"p99": 10.256543029999994
26+
"min": 2.728025,
27+
"p50": 4.021591,
28+
"max": 19.584786,
29+
"avg": 4.42298415647406,
30+
"p90": 6.1084814000000005,
31+
"p95": 7.541213199999999,
32+
"p99": 10.568311520000002
3333
},
3434
"throughput": {
35-
"requests_per_second": 78.58481605231692,
36-
"total_iterations": 7151
35+
"requests_per_second": 78.51376777039454,
36+
"total_iterations": 7144
3737
},
3838
"reliability": {
3939
"error_rate": 0

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

Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
using System.Collections.Immutable;
21
using HotChocolate.Fusion.Events.Contracts;
3-
using HotChocolate.Language;
42
using HotChocolate.Types;
53
using HotChocolate.Types.Mutable;
64

75
namespace HotChocolate.Fusion.Events;
86

7+
internal record ComplexTypeEvent(
8+
MutableComplexTypeDefinition ComplexType,
9+
MutableSchemaDefinition Schema) : IEvent;
10+
911
internal record DirectiveArgumentEvent(
1012
MutableInputFieldDefinition Argument,
1113
MutableDirectiveDefinition Directive,
@@ -34,57 +36,6 @@ internal record InterfaceTypeEvent(
3436
MutableInterfaceTypeDefinition InterfaceType,
3537
MutableSchemaDefinition Schema) : IEvent;
3638

37-
internal record IsDirectiveEvent(
38-
Directive IsDirective,
39-
MutableInputFieldDefinition Argument,
40-
MutableOutputFieldDefinition Field,
41-
MutableComplexTypeDefinition Type,
42-
MutableSchemaDefinition Schema) : IEvent;
43-
44-
internal record IsFieldInvalidSyntaxEvent(
45-
Directive IsDirective,
46-
MutableInputFieldDefinition Argument,
47-
MutableOutputFieldDefinition Field,
48-
MutableComplexTypeDefinition Type,
49-
MutableSchemaDefinition Schema) : IEvent;
50-
51-
internal record IsFieldInvalidTypeEvent(
52-
Directive IsDirective,
53-
MutableInputFieldDefinition Argument,
54-
MutableOutputFieldDefinition Field,
55-
MutableComplexTypeDefinition Type,
56-
MutableSchemaDefinition Schema) : IEvent;
57-
58-
internal record KeyFieldEvent(
59-
MutableOutputFieldDefinition KeyField,
60-
MutableComplexTypeDefinition KeyFieldDeclaringType,
61-
Directive KeyDirective,
62-
MutableComplexTypeDefinition Type,
63-
MutableSchemaDefinition Schema) : IEvent;
64-
65-
internal record KeyFieldNodeEvent(
66-
FieldNode FieldNode,
67-
ImmutableArray<string> FieldNamePath,
68-
Directive KeyDirective,
69-
MutableComplexTypeDefinition Type,
70-
MutableSchemaDefinition Schema) : IEvent;
71-
72-
internal record KeyFieldsEvent(
73-
SelectionSetNode SelectionSet,
74-
Directive KeyDirective,
75-
MutableComplexTypeDefinition Type,
76-
MutableSchemaDefinition Schema) : IEvent;
77-
78-
internal record KeyFieldsInvalidSyntaxEvent(
79-
Directive KeyDirective,
80-
MutableComplexTypeDefinition Type,
81-
MutableSchemaDefinition Schema) : IEvent;
82-
83-
internal record KeyFieldsInvalidTypeEvent(
84-
Directive KeyDirective,
85-
MutableComplexTypeDefinition Type,
86-
MutableSchemaDefinition Schema) : IEvent;
87-
8839
internal record ObjectTypeEvent(
8940
MutableObjectTypeDefinition ObjectType,
9041
MutableSchemaDefinition Schema) : IEvent;
@@ -94,55 +45,6 @@ internal record OutputFieldEvent(
9445
ITypeDefinition Type,
9546
MutableSchemaDefinition Schema) : IEvent;
9647

97-
internal record ProvidesFieldEvent(
98-
MutableOutputFieldDefinition ProvidedField,
99-
MutableComplexTypeDefinition ProvidedType,
100-
Directive ProvidesDirective,
101-
MutableOutputFieldDefinition Field,
102-
MutableComplexTypeDefinition Type,
103-
MutableSchemaDefinition Schema) : IEvent;
104-
105-
internal record ProvidesFieldNodeEvent(
106-
FieldNode FieldNode,
107-
ImmutableArray<string> FieldNamePath,
108-
Directive ProvidesDirective,
109-
MutableOutputFieldDefinition Field,
110-
MutableComplexTypeDefinition Type,
111-
MutableSchemaDefinition Schema) : IEvent;
112-
113-
internal record ProvidesFieldsEvent(
114-
SelectionSetNode SelectionSet,
115-
Directive ProvidesDirective,
116-
MutableOutputFieldDefinition Field,
117-
MutableComplexTypeDefinition Type,
118-
MutableSchemaDefinition Schema) : IEvent;
119-
120-
internal record ProvidesFieldsInvalidSyntaxEvent(
121-
Directive ProvidesDirective,
122-
MutableOutputFieldDefinition Field,
123-
MutableComplexTypeDefinition Type,
124-
MutableSchemaDefinition Schema) : IEvent;
125-
126-
internal record ProvidesFieldsInvalidTypeEvent(
127-
Directive ProvidesDirective,
128-
MutableOutputFieldDefinition Field,
129-
MutableComplexTypeDefinition Type,
130-
MutableSchemaDefinition Schema) : IEvent;
131-
132-
internal record RequireFieldInvalidSyntaxEvent(
133-
Directive RequireDirective,
134-
MutableInputFieldDefinition Argument,
135-
MutableOutputFieldDefinition Field,
136-
MutableComplexTypeDefinition Type,
137-
MutableSchemaDefinition Schema) : IEvent;
138-
139-
internal record RequireFieldInvalidTypeEvent(
140-
Directive RequireDirective,
141-
MutableInputFieldDefinition Argument,
142-
MutableOutputFieldDefinition Field,
143-
MutableComplexTypeDefinition Type,
144-
MutableSchemaDefinition Schema) : IEvent;
145-
14648
internal record SchemaEvent(MutableSchemaDefinition Schema) : IEvent;
14749

14850
internal record TypeEvent(

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

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ public static bool ExistsInSchema(this IDirectivesProvider type, string schemaNa
6161
&& (string)d.Arguments[ArgumentNames.Schema].Value! == schemaName);
6262
}
6363

64-
public static bool HasExternalDirective(this IDirectivesProvider type)
65-
{
66-
return type.Directives.ContainsName(WellKnownDirectiveNames.External);
67-
}
68-
6964
public static bool HasFusionInaccessibleDirective(this IDirectivesProvider type)
7065
{
7166
return type.Directives.ContainsName(WellKnownDirectiveNames.FusionInaccessible);
@@ -75,34 +70,4 @@ public static bool HasInaccessibleDirective(this IDirectivesProvider type)
7570
{
7671
return type.Directives.ContainsName(WellKnownDirectiveNames.Inaccessible);
7772
}
78-
79-
public static bool HasIsDirective(this IDirectivesProvider type)
80-
{
81-
return type.Directives.ContainsName(WellKnownDirectiveNames.Is);
82-
}
83-
84-
public static bool HasLookupDirective(this IDirectivesProvider type)
85-
{
86-
return type.Directives.ContainsName(WellKnownDirectiveNames.Lookup);
87-
}
88-
89-
public static bool HasOverrideDirective(this IDirectivesProvider type)
90-
{
91-
return type.Directives.ContainsName(WellKnownDirectiveNames.Override);
92-
}
93-
94-
public static bool HasProvidesDirective(this IDirectivesProvider type)
95-
{
96-
return type.Directives.ContainsName(WellKnownDirectiveNames.Provides);
97-
}
98-
99-
public static bool HasRequireDirective(this IDirectivesProvider type)
100-
{
101-
return type.Directives.ContainsName(WellKnownDirectiveNames.Require);
102-
}
103-
104-
public static bool HasShareableDirective(this IDirectivesProvider type)
105-
{
106-
return type.Directives.ContainsName(WellKnownDirectiveNames.Shareable);
107-
}
10873
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using HotChocolate.Features;
2+
using HotChocolate.Fusion.Features;
13
using HotChocolate.Language;
24
using HotChocolate.Types;
35
using HotChocolate.Types.Mutable;
@@ -29,4 +31,10 @@ public static IEnumerable<Directive> GetKeyDirectives(this MutableComplexTypeDef
2931
{
3032
return type.Directives.AsEnumerable().Where(d => d.Name == DirectiveNames.Key);
3133
}
34+
35+
extension(MutableComplexTypeDefinition complexType)
36+
{
37+
public Dictionary<Directive, KeyInfo> KeyInfoByDirective
38+
=> complexType.Features.GetOrSet<SourceComplexTypeMetadata>().KeyInfoByDirective;
39+
}
3240
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using HotChocolate.Features;
2+
using HotChocolate.Fusion.Features;
3+
using HotChocolate.Types.Mutable;
4+
5+
namespace HotChocolate.Fusion.Extensions;
6+
7+
internal static class MutableEnumValueDefinitionExtensions
8+
{
9+
extension(MutableEnumValue enumValue)
10+
{
11+
/// <summary>
12+
/// Gets a value indicating whether the enum value or its declaring type is marked as
13+
/// inaccessible.
14+
/// </summary>
15+
public bool IsInaccessible
16+
=> enumValue.Features.GetRequired<SourceEnumValueMetadata>().IsInaccessible;
17+
}
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using HotChocolate.Features;
2+
using HotChocolate.Fusion.Features;
3+
using HotChocolate.Types.Mutable;
4+
5+
namespace HotChocolate.Fusion.Extensions;
6+
7+
internal static class MutableInputFieldDefinitionExtensions
8+
{
9+
extension(MutableInputFieldDefinition inputField)
10+
{
11+
public bool HasIsDirective
12+
=> inputField.Features.GetRequired<SourceInputFieldMetadata>().HasIsDirective;
13+
14+
public bool HasRequireDirective
15+
=> inputField.Features.GetRequired<SourceInputFieldMetadata>().HasRequireDirective;
16+
17+
/// <summary>
18+
/// Gets a value indicating whether the input field or its declaring member is inaccessible.
19+
/// </summary>
20+
public bool IsInaccessible
21+
=> inputField.Features.GetRequired<SourceInputFieldMetadata>().IsInaccessible;
22+
23+
public IsInfo? IsInfo
24+
=> inputField.Features.GetRequired<SourceInputFieldMetadata>().IsInfo;
25+
26+
public RequireInfo? RequireInfo
27+
=> inputField.Features.GetRequired<SourceInputFieldMetadata>().RequireInfo;
28+
}
29+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
using HotChocolate.Features;
2+
using HotChocolate.Fusion.Features;
13
using HotChocolate.Types.Mutable;
2-
using DirectiveNames = HotChocolate.Fusion.WellKnownDirectiveNames;
34

45
namespace HotChocolate.Fusion.Extensions;
56

67
internal static class MutableObjectTypeDefinitionExtensions
78
{
8-
public static bool HasInternalDirective(this MutableObjectTypeDefinition type)
9+
extension(MutableObjectTypeDefinition objectType)
910
{
10-
return type.Directives.ContainsName(DirectiveNames.Internal);
11+
public bool HasShareableDirective
12+
=> objectType.Features.GetRequired<SourceObjectTypeMetadata>().HasShareableDirective;
13+
14+
public bool IsInternal
15+
=> objectType.Features.GetRequired<SourceObjectTypeMetadata>().IsInternal;
1116
}
1217
}

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

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System.Collections.Immutable;
2+
using HotChocolate.Features;
3+
using HotChocolate.Fusion.Features;
24
using HotChocolate.Fusion.Language;
35
using HotChocolate.Fusion.Rewriters;
46
using HotChocolate.Language;
@@ -104,11 +106,6 @@ public static string GetKeyFields(
104106
return (string?)overrideDirective?.Arguments[ArgumentNames.From].Value;
105107
}
106108

107-
public static bool HasInternalDirective(this MutableOutputFieldDefinition field)
108-
{
109-
return field.Directives.ContainsName(DirectiveNames.Internal);
110-
}
111-
112109
public static bool IsPartial(this MutableOutputFieldDefinition field, string schemaName)
113110
{
114111
var fusionFieldDirective =
@@ -129,4 +126,49 @@ public static bool IsPartial(this MutableOutputFieldDefinition field, string sch
129126

130127
return false;
131128
}
129+
130+
extension(MutableOutputFieldDefinition outputField)
131+
{
132+
public bool HasExternalDirective
133+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().HasExternalDirective;
134+
135+
public bool HasInternalDirective
136+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().HasInternalDirective;
137+
138+
public bool HasOverrideDirective
139+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().HasOverrideDirective;
140+
141+
public bool HasProvidesDirective
142+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().HasProvidesDirective;
143+
144+
public bool HasShareableDirective
145+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().HasShareableDirective;
146+
147+
public bool IsExternal
148+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().IsExternal;
149+
150+
/// <summary>
151+
/// Gets a value indicating whether the field or its declaring type is marked as inaccessible.
152+
/// </summary>
153+
public bool IsInaccessible
154+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().IsInaccessible;
155+
156+
/// <summary>
157+
/// Gets a value indicating whether the field or its declaring type is marked as internal.
158+
/// </summary>
159+
public bool IsInternal
160+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().IsInternal;
161+
162+
public bool IsLookup
163+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().IsLookup;
164+
165+
public bool IsOverridden
166+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().IsOverridden;
167+
168+
public bool IsShareable
169+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().IsShareable;
170+
171+
public ProvidesInfo? ProvidesInfo
172+
=> outputField.Features.GetRequired<SourceOutputFieldMetadata>().ProvidesInfo;
173+
}
132174
}

0 commit comments

Comments
 (0)