Skip to content

Commit ed5ac28

Browse files
authored
[Fusion] Excluded built-in source schema scalar types from being merged (#8249)
1 parent 5c41a1a commit ed5ac28

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using static HotChocolate.Fusion.WellKnownTypeNames;
2+
3+
namespace HotChocolate.Fusion;
4+
5+
internal static class FusionBuiltIns
6+
{
7+
public static bool IsBuiltInSourceSchemaScalar(string typeName)
8+
{
9+
return typeName switch
10+
{
11+
FieldSelectionMap or FieldSelectionSet => true,
12+
_ => false
13+
};
14+
}
15+
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,19 @@ .. typeGroup.Where(
574574
/// <seealso href="https://graphql.github.io/composite-schemas-spec/draft/#sec-Merge-Scalar-Types">
575575
/// Specification
576576
/// </seealso>
577-
private MutableScalarTypeDefinition MergeScalarTypes(
577+
private MutableScalarTypeDefinition? MergeScalarTypes(
578578
ImmutableArray<TypeInfo> typeGroup,
579579
MutableSchemaDefinition mergedSchema)
580580
{
581581
var firstScalar = typeGroup[0].Type;
582582
var typeName = firstScalar.Name;
583+
584+
// Built-in Fusion scalar types should not be merged.
585+
if (FusionBuiltIns.IsBuiltInSourceSchemaScalar(typeName))
586+
{
587+
return null;
588+
}
589+
583590
var description = firstScalar.Description;
584591
var scalarType = GetOrCreateType<MutableScalarTypeDefinition>(mergedSchema, typeName);
585592

src/HotChocolate/Fusion-vnext/test/Fusion.Composition.Tests/SourceSchemaMerger.Scalar.Tests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ scalar Date
107107
@fusion__type(schema: A)
108108
@fusion__type(schema: B)
109109
"""
110+
},
111+
// Built-in Fusion scalar types should not be merged (FieldSelectionSet/Map).
112+
{
113+
[
114+
"""
115+
# Schema A
116+
directive @provides(fields: FieldSelectionSet!) on FIELD_DEFINITION
117+
directive @require(field: FieldSelectionMap!) on ARGUMENT_DEFINITION
118+
"""
119+
],
120+
""
110121
}
111122
};
112123
}

0 commit comments

Comments
 (0)