diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationPlanner.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationPlanner.cs index 32554bada2c..30464de59a7 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationPlanner.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationPlanner.cs @@ -169,6 +169,14 @@ private bool TryPlanInlineFragmentSelection( }); } + if (unresolvedSelections is { Count: > 0 }) + { + var unresolvedInlineFragment = + new UnresolvedInlineFragment(inlineFragmentNode.Directives, typeCondition, unresolvedSelections); + + trackUnresolvedSelection(unresolvedInlineFragment); + } + if (inlineFragmentPlanNode.Selections.Count > 0) { AddSelectionDirectives(inlineFragmentPlanNode, inlineFragmentNode.Directives); @@ -178,14 +186,6 @@ private bool TryPlanInlineFragmentSelection( return true; } - if (unresolvedSelections is { Count: > 0 }) - { - var unresolvedInlineFragment = - new UnresolvedInlineFragment(inlineFragmentNode.Directives, typeCondition, unresolvedSelections); - - trackUnresolvedSelection(unresolvedInlineFragment); - } - return false; } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipFragmentTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipFragmentTests.cs index 84864973be9..f405c9cedb1 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipFragmentTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipFragmentTests.cs @@ -882,4 +882,33 @@ fragment ProductFragment2 on Product { // assert plan.MatchSnapshot(); } + + + + [Test] + public void Skipped_Sub_Fragment_With_Fields_From_Different_Subgraphs() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + ... ProductFragment @skip(if: $skip) + } + } + + fragment ProductFragment on Product { + name + averageRating + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipFragmentTests.Skipped_Sub_Fragment_With_Fields_From_Different_Subgraphs.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipFragmentTests.Skipped_Sub_Fragment_With_Fields_From_Different_Subgraphs.yaml new file mode 100644 index 00000000000..21ab6c7ff17 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipFragmentTests.Skipped_Sub_Fragment_With_Fields_From_Different_Subgraphs.yaml @@ -0,0 +1,39 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + ... on Product @skip(if: $skip) { + name + averageRating + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + ... on Product @skip(if: $skip) { + name + } + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + ... on Product { + averageRating + } + } + } + skipIf: "skip" + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!"