Skip to content

Commit 255e6ad

Browse files
authored
[Fusion] Reverted changes ensuring unique schema name enum values (#8963)
1 parent 6174e0b commit 255e6ad

File tree

3 files changed

+1
-58
lines changed

3 files changed

+1
-58
lines changed

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public SourceSchemaMerger(
4242
SourceSchemaMergerOptions? options = null)
4343
{
4444
_schemas = schemas;
45-
_schemaConstantNames = CreateSchemaConstantNames(schemas);
45+
_schemaConstantNames = schemas.ToFrozenDictionary(s => s.Name, s => ToConstantCase(s.Name));
4646
_options = options ?? new SourceSchemaMergerOptions();
4747
_fusionTypeDefinitions = CreateFusionTypeDefinitions();
4848
_fusionDirectiveDefinitions = CreateFusionDirectiveDefinitions();
@@ -100,30 +100,6 @@ public CompositionResult<MutableSchemaDefinition> Merge()
100100
return mergedSchema;
101101
}
102102

103-
private static FrozenDictionary<string, string> CreateSchemaConstantNames(
104-
ImmutableSortedSet<MutableSchemaDefinition> schemas)
105-
{
106-
var schemaConstantNames = new Dictionary<string, string>();
107-
var counters = new Dictionary<string, int>();
108-
109-
foreach (var schema in schemas)
110-
{
111-
var constantName = ToConstantCase(schema.Name);
112-
113-
if (schemaConstantNames.ContainsValue(constantName))
114-
{
115-
var counterValue = counters.GetValueOrDefault(constantName, 0);
116-
counters[constantName] = ++counterValue;
117-
118-
constantName += $"_{counterValue}";
119-
}
120-
121-
schemaConstantNames[schema.Name] = constantName;
122-
}
123-
124-
return schemaConstantNames.ToFrozenDictionary();
125-
}
126-
127103
private void MergeDirectiveDefinitions(MutableSchemaDefinition mergedSchema)
128104
{
129105
// [DirectiveName: [{DirectiveDefinition, Schema}, ...], ...].

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,31 +112,6 @@ public void Merge_FourNamedSchemas_AddsFusionDefinitions()
112112
SchemaFormatter.FormatAsString(result.Value).MatchSnapshot(extension: ".graphql");
113113
}
114114

115-
[Fact]
116-
public void Merge_ConflictingSchemaNames_UsesUniqueSchemaEnumValues()
117-
{
118-
// arrange
119-
IEnumerable<MutableSchemaDefinition> schemas =
120-
[
121-
new() { Name = "Example.Name" },
122-
new() { Name = "Example-Name" },
123-
new() { Name = "Example_Name" },
124-
new() { Name = "AnotherName" },
125-
new() { Name = "AnotherNAME" }
126-
];
127-
128-
var merger = new SourceSchemaMerger(
129-
schemas.ToImmutableSortedSet(
130-
new SchemaByNameComparer<MutableSchemaDefinition>()));
131-
132-
// act
133-
var result = merger.Merge();
134-
135-
// assert
136-
Assert.True(result.IsSuccess);
137-
result.Value.Types["fusion__Schema"].ToString().MatchSnapshot(extension: ".graphql");
138-
}
139-
140115
[Fact]
141116
public void Merge_WithRequireInputObject_RetainsInputObjectType()
142117
{

src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/__snapshots__/SourceSchemaMergerTests.Merge_ConflictingSchemaNames_UsesUniqueSchemaEnumValues.graphql

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

0 commit comments

Comments
 (0)