Skip to content

Commit 173510c

Browse files
committed
More work
1 parent 5a701ae commit 173510c

37 files changed

Lines changed: 2225 additions & 449 deletions

File tree

src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/VariableMergingBenchmark.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ private static OperationRequirement Requirement(string key)
196196
key,
197197
new NamedTypeNode("String"),
198198
SelectionPath.Root,
199-
new PathNode(new PathSegmentNode(new FusionNameNode(key))));
199+
new PathNode(new PathSegmentNode(new FusionNameNode(key))),
200+
null);
200201

201202
private static CompactPath Path(params int[] segments)
202203
{

src/HotChocolate/Fusion/src/Fusion.Composition/ApolloFederation/RemoveExternalFields.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,32 @@ private static bool IsReferencedByOutputField(
253253
outputType,
254254
out var selectedFields);
255255

256+
// A @require map that traverses an object- or interface-typed
257+
// intermediate (a nested selection such as
258+
// "dimensions { size weight }") keeps its ENTIRE subtree with
259+
// @external intact: the intermediate path field has to stay
260+
// traversable and its leaf fields belong to the same non-resolvable
261+
// input contribution, so dropping them would leave the intermediate
262+
// type empty. A map that is a flat, root-level scalar requirement
263+
// (such as "price") keeps nothing: its external leaf is removed so it
264+
// never competes with its real owner as a spurious partial
265+
// contribution.
266+
var hasComplexIntermediate = false;
267+
268+
foreach (var selectedField in selectedFields)
269+
{
270+
if (selectedField.Type.NamedType() is IComplexTypeDefinition)
271+
{
272+
hasComplexIntermediate = true;
273+
break;
274+
}
275+
}
276+
277+
if (!hasComplexIntermediate)
278+
{
279+
continue;
280+
}
281+
256282
foreach (var selectedField in selectedFields)
257283
{
258284
var coordinate = selectedField.Coordinate;

src/HotChocolate/Fusion/src/Fusion.Execution/Execution/ApolloFederation/RepresentationShape.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ internal sealed class RepresentationShapeNode
9999
/// or <c>null</c> when unconditional.
100100
/// </summary>
101101
public string? TypeCondition { get; set; }
102+
103+
/// <summary>
104+
/// Gets whether the emitter must write the runtime <c>__typename</c> into
105+
/// this composite node's object. This is set when the node's declared type
106+
/// is abstract and the node carries no type-conditioned branches, so the
107+
/// source schema cannot reconstruct the abstract value without its type name.
108+
/// </summary>
109+
public bool RequiresTypeName { get; set; }
102110
}
103111

104112
/// <summary>

0 commit comments

Comments
 (0)