Skip to content

Commit 8dfeac5

Browse files
authored
[Fusion] Updated MergeUnionTypes to allow empty merged union type (#7984)
1 parent c0192a1 commit 8dfeac5

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,7 @@ private ScalarTypeDefinition MergeScalarTypes(ImmutableArray<TypeInfo> typeGroup
560560
.Where(i => !i.MemberType.HasInternalDirective())
561561
.GroupBy(i => i.MemberType.Name)
562562
// Intersection: Member type definition count matches union type definition count.
563-
.Where(g => g.Count() == typeGroup.Length)
564-
.ToImmutableArray();
565-
566-
if (unionMemberGroupByName.Length == 0)
567-
{
568-
return null;
569-
}
563+
.Where(g => g.Count() == typeGroup.Length);
570564

571565
var unionType = new UnionTypeDefinition(name) { Description = description };
572566

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ union SearchResult
143143
"""
144144
},
145145
// Each union's possible types are considered in turn. Only those that are not marked
146-
// @internal are included in the final composed union. This preserves the valid types
147-
// from all sources while systematically filtering out anything intended for internal
148-
// use only. In case there are no possible types left after filtering, the merged union
149-
// is considered @internal and cannot appear in the final schema.
146+
// @internal or @inaccessible are included in the final composed union. This preserves
147+
// the valid types from all sources while systematically filtering out anything
148+
// inaccessible or intended for internal use only.
150149
{
151150
[
152151
"""
@@ -162,7 +161,11 @@ union SearchResult
162161
type User @internal { id: ID! }
163162
"""
164163
],
165-
""
164+
"""
165+
union SearchResult
166+
@fusion__type(schema: A)
167+
@fusion__type(schema: B) =
168+
"""
166169
},
167170
// Union member type "User" internal in one of two schemas. No remaining member types.
168171
{
@@ -186,6 +189,10 @@ type User
186189
id: ID!
187190
@fusion__field(schema: A)
188191
}
192+
193+
union SearchResult
194+
@fusion__type(schema: A)
195+
@fusion__type(schema: B) =
189196
"""
190197
},
191198
// Union member type "Order" internal in one of two schemas, "Product" visible in both.

0 commit comments

Comments
 (0)