Skip to content

Commit 7708d98

Browse files
authored
[Fusion] Updated tests to use the SourceSchemaParser (#8712)
1 parent 1d32c6f commit 7708d98

File tree

11 files changed

+144
-331
lines changed

11 files changed

+144
-331
lines changed

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/HotChocolate.Fusion.Composition.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ItemGroup>
99
<InternalsVisibleTo Include="HotChocolate.Fusion.Composition.Tests" />
1010
<InternalsVisibleTo Include="HotChocolate.Fusion.Execution.Tests" />
11+
<InternalsVisibleTo Include="HotChocolate.Fusion.Utilities.Tests" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SchemaComposer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public CompositionResult<MutableSchemaDefinition> Compose()
122122
new RequireInvalidSyntaxRule(),
123123
new RootMutationUsedRule(),
124124
new RootQueryUsedRule(),
125-
new RootSubscriptionUsedRule(),
126-
new TypeDefinitionInvalidRule()
125+
new RootSubscriptionUsedRule()
127126
];
128127

129128
private static readonly ImmutableArray<object> s_preMergeRules =

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaValidationRules/TypeDefinitionInvalidRule.cs

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Immutable;
2-
using HotChocolate.Fusion.Comparers;
2+
using HotChocolate.Fusion.Logging;
33
using HotChocolate.Types.Mutable;
4-
using HotChocolate.Types.Mutable.Serialization;
54

65
namespace HotChocolate.Fusion;
76

@@ -10,16 +9,11 @@ internal static class CompositionTestHelper
109
internal static ImmutableSortedSet<MutableSchemaDefinition> CreateSchemaDefinitions(
1110
string[] sdl)
1211
{
13-
var schemaDefinitions =
14-
sdl.Select((s, i) =>
15-
{
16-
var schemaDefinition = SchemaParser.Parse(s);
17-
schemaDefinition.Name = ((char)('A' + i)).ToString();
12+
var sourceSchemaParser =
13+
new SourceSchemaParser(
14+
sdl.Select((s, i) => new SourceSchemaText(((char)('A' + i)).ToString(), s)),
15+
new CompositionLog());
1816

19-
return schemaDefinition;
20-
});
21-
22-
return schemaDefinitions.ToImmutableSortedSet(
23-
new SchemaByNameComparer<MutableSchemaDefinition>());
17+
return sourceSchemaParser.Parse().Value;
2418
}
2519
}

src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/SatisfiabilityValidatorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ type A
967967
pId: ID!
968968
compositeId: CompositeID!
969969
name: String! @external
970-
nameInB: String! @requires(fields: "name")
970+
nameInB: String! @require(fields: "name")
971971
}
972972
973973
type CompositeID {
@@ -1026,7 +1026,7 @@ type Product @key(fields: "id") {
10261026
type Product @key(fields: "id") {
10271027
id: ID!
10281028
price: Float! @external
1029-
isExpensive: Boolean! @requires(fields: "price")
1029+
isExpensive: Boolean! @require(fields: "price")
10301030
isAvailable: Boolean!
10311031
}
10321032

src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/SourceSchemaMergerTests.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Immutable;
22
using HotChocolate.Fusion.Comparers;
3+
using HotChocolate.Fusion.Logging;
34
using HotChocolate.Types.Mutable;
45
using HotChocolate.Types.Mutable.Serialization;
56
using static HotChocolate.Fusion.WellKnownTypeNames;
@@ -102,8 +103,9 @@ public void Merge_FourNamedSchemas_AddsFusionDefinitions()
102103
public void Merge_WithRequireInputObject_RetainsInputObjectType()
103104
{
104105
// arrange
105-
var schemaA =
106-
SchemaParser.Parse(
106+
var sourceSchemaTextA =
107+
new SourceSchemaText(
108+
"A",
107109
"""
108110
type Query {
109111
product: Product
@@ -113,9 +115,9 @@ type Product {
113115
weight: Int!
114116
}
115117
""");
116-
schemaA.Name = "A";
117-
var schemaB =
118-
SchemaParser.Parse(
118+
var sourceSchemaTextB =
119+
new SourceSchemaText(
120+
"B",
119121
"""
120122
type Product {
121123
deliveryEstimate(
@@ -128,11 +130,8 @@ input ProductDimensionInput @inaccessible {
128130
weight: Int!
129131
}
130132
""");
131-
schemaB.Name = "B";
132-
IEnumerable<MutableSchemaDefinition> schemas = [schemaA, schemaB];
133-
var merger = new SourceSchemaMerger(
134-
schemas.ToImmutableSortedSet(
135-
new SchemaByNameComparer<MutableSchemaDefinition>()));
133+
var sourceSchemaParser = new SourceSchemaParser([sourceSchemaTextA, sourceSchemaTextB], new CompositionLog());
134+
var merger = new SourceSchemaMerger(sourceSchemaParser.Parse().Value);
136135

137136
// act
138137
var result = merger.Merge();

src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/SourceSchemaValidationRules/TypeDefinitionInvalidRuleTests.cs

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

src/HotChocolate/Fusion-vnext/test/Fusion.Utilities.Tests/HotChocolate.Fusion.Utilities.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<ProjectReference Include="..\..\src\Fusion.Composition\HotChocolate.Fusion.Composition.csproj" />
1011
<ProjectReference Include="..\..\src\Fusion.Utilities\HotChocolate.Fusion.Utilities.csproj" />
1112
<ProjectReference Include="..\..\..\Mutable\src\Types.Mutable\HotChocolate.Types.Mutable.csproj" />
1213
</ItemGroup>

0 commit comments

Comments
 (0)