diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/InlineFragmentOperationRewriter.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/InlineFragmentOperationRewriter.cs index ad8bfd8656e..f7ac20e75e8 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/InlineFragmentOperationRewriter.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/InlineFragmentOperationRewriter.cs @@ -135,7 +135,7 @@ private void InlineFragmentDefinition( { var fragmentContext = context.Branch(typeCondition); - RewriteFields(fragmentDefinition.SelectionSet, context); + RewriteFields(fragmentDefinition.SelectionSet, fragmentContext); var selectionSet = new SelectionSetNode( null, diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/Nodes/SelectionPlanNode.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/Nodes/SelectionPlanNode.cs index ce8cfc9fe12..1837460805d 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/Nodes/SelectionPlanNode.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/Nodes/SelectionPlanNode.cs @@ -152,7 +152,7 @@ public bool RemoveDirective(CompositeDirective directive) private void InitializeConditions() { - if(_isConditional.HasValue) + if (_isConditional.HasValue) { return; } @@ -170,7 +170,7 @@ private void InitializeConditions() continue; } - if (directive.Name.Value.Equals("skip")) + if (directive.Name.Value.Equals("include")) { _includeVariable = GetVariableName(directive); } 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 c49410dd26a..e8d0ab60417 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationPlanner.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationPlanner.cs @@ -31,7 +31,7 @@ public RequestPlanNode CreatePlan(DocumentNode document, string? operationName) var context = new PlaningContext(operation, operation, ImmutableStack.Empty); if (TryPlanSelectionSet(context)) { - PlanConditionNode(operation, operation.Selections); + TryMakeOperationConditional(operation, operation.Selections); operationPlan.AddOperation(operation); } } @@ -275,7 +275,7 @@ private bool TryHandleUnresolvedSelections( } schemasInContext.Add(schemaName, lookupOperation); - PlanConditionNode(lookupOperation, lookupField.Selections); + TryMakeOperationConditional(lookupOperation, lookupField.Selections); // we add the lookup operation to all the schemas that we have requirements with. foreach (var requiredSchema in fieldSchemaDependencies.Values.Distinct()) @@ -607,7 +607,7 @@ private static FieldNode CreateFieldNodeFromPath(FieldPath path) return current!; } - private void PlanConditionNode( + private void TryMakeOperationConditional( OperationPlanNode operation, IReadOnlyList selections) { @@ -655,9 +655,8 @@ private void PlanConditionNode( } } - private bool IsSelectionAlwaysSkipped(ISelectionNode selectionNode) + private static bool IsSelectionAlwaysSkipped(ISelectionNode selectionNode) { - var selectionIsSkipped = false; foreach (var directive in selectionNode.Directives) { var isSkipDirective = directive.Name.Value == "skip"; @@ -673,26 +672,19 @@ private bool IsSelectionAlwaysSkipped(ISelectionNode selectionNode) { if (booleanValueNode.Value && isSkipDirective) { - selectionIsSkipped = true; + return true; } - else if (!booleanValueNode.Value && isIncludedDirective) - { - selectionIsSkipped = true; - } - else + + if (!booleanValueNode.Value && isIncludedDirective) { - selectionIsSkipped = false; + return true; } } - else - { - selectionIsSkipped = false; - } } } } - return selectionIsSkipped; + return false; } private string GetNextRequirementName() diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationVariableBinder.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationVariableBinder.cs index cb2b8d4ef18..239b70685f5 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationVariableBinder.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/OperationVariableBinder.cs @@ -9,7 +9,7 @@ public static void BindOperationVariables( OperationDefinitionNode operationDefinition, RequestPlanNode operationPlan) { - var operationBacklog = new Stack(operationPlan.Operations.OfType()); + var operationBacklog = new Stack(operationPlan.Operations); var selectionBacklog = new Stack(); var variableDefinitions = operationDefinition.VariableDefinitions.ToDictionary(t => t.Variable.Name.Value); var usedVariables = new HashSet(); @@ -18,7 +18,7 @@ public static void BindOperationVariables( { CollectAndBindUsedVariables(operation, variableDefinitions, usedVariables, selectionBacklog); - foreach (var child in operation.Dependants.OfType()) + foreach (var child in operation.Dependants) { operationBacklog.Push(child); } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/PlanNodeYamlFormatter.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/PlanNodeYamlFormatter.cs index 43b35d63c73..11a34b8f699 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/PlanNodeYamlFormatter.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/PlanNodeYamlFormatter.cs @@ -1,4 +1,5 @@ using System.Buffers; +using System.Buffers.Text; using System.Text; using System.Text.Json; using HotChocolate.Fusion.Planning.Nodes; @@ -77,7 +78,7 @@ private static void WriteOperationNode( if (operation.IncludeVariable is not null) { - writer.WriteLine(" includeIf: \"{0}\"", operation.SkipVariable); + writer.WriteLine(" includeIf: \"{0}\"", operation.IncludeVariable); } if (operation.Requirements.Count > 0) diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests.cs deleted file mode 100644 index 70579d76eb0..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests.cs +++ /dev/null @@ -1,829 +0,0 @@ -using HotChocolate.Fusion.Planning; - -namespace HotChocolate.Fusion; - -public class ConditionTests : FusionTestBase -{ - [Test] - public void Skip_On_SubField() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!) { - productById(id: $id) { - name @skip(if: $skip) - description - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!, $skip: Boolean!) { - productById(id: $id) { - name @skip(if: $skip) - description - } - } - - """); - } - - [Test] - public void Skip_On_SubField_If_False() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name @skip(if: false) - description - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - description - } - } - - """); - } - - [Test] - public void Skip_On_SubField_If_True() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name @skip(if: true) - description - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - description - } - } - - """); - } - - [Test] - public void Skip_On_SubField_Only_Skipped_Field_Selected() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!) { - productById(id: $id) { - name @skip(if: $skip) - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!, $skip: Boolean!) { - productById(id: $id) { - name @skip(if: $skip) - } - } - - """); - } - - [Test] - public void Skip_On_SubField_Only_Skipped_Field_Selected_If_False() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name @skip(if: false) - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - } - } - - """); - } - - [Test] - public void Skip_On_SubField_Only_Skipped_Field_Selected_If_True() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name @skip(if: true) - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - __typename - } - } - - """); - } - - [Test] - public void Skip_On_SubField_Resolved_From_Other_Source() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!) { - productById(id: $id) { - name - averageRating - reviews(first: 10) @skip(if: $skip) { - nodes { - body - } - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - id - } - } - - id: 2 - schema: "REVIEWS" - operation: >- - query($__fusion_requirement_1: ID!, $skip: Boolean!) { - productById(id: $__fusion_requirement_1) { - averageRating - reviews(first: 10) @skip(if: $skip) { - nodes { - body - } - } - } - } - requirements: - - name: "__fusion_requirement_1" - dependsOn: "1" - selectionSet: "productById" - field: "id" - type: "ID!" - - """); - } - - [Test] - public void Skip_On_SubField_Resolved_From_Other_Source_If_False() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name - averageRating - reviews(first: 10) @skip(if: false) { - nodes { - body - } - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - id - } - } - - id: 2 - schema: "REVIEWS" - operation: >- - query($__fusion_requirement_1: ID!) { - productById(id: $__fusion_requirement_1) { - averageRating - reviews(first: 10) { - nodes { - body - } - } - } - } - requirements: - - name: "__fusion_requirement_1" - dependsOn: "1" - selectionSet: "productById" - field: "id" - type: "ID!" - - """); - } - - [Test] - public void Skip_On_SubField_Resolved_From_Other_Source_If_True() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name - averageRating - reviews(first: 10) @skip(if: true) { - nodes { - body - } - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - id - } - } - - id: 2 - schema: "REVIEWS" - operation: >- - query($__fusion_requirement_1: ID!) { - productById(id: $__fusion_requirement_1) { - averageRating - } - } - requirements: - - name: "__fusion_requirement_1" - dependsOn: "1" - selectionSet: "productById" - field: "id" - type: "ID!" - - """); - } - - [Test] - public void Skip_On_SubField_Resolved_From_Other_Source_Only_Skipped_Field_Selected() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!) { - productById(id: $id) { - name - reviews(first: 10) @skip(if: $skip) { - nodes { - body - } - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - id - } - } - - id: 2 - schema: "REVIEWS" - operation: >- - query($__fusion_requirement_1: ID!) { - productById(id: $__fusion_requirement_1) { - reviews(first: 10) { - nodes { - body - } - } - } - } - skipIf: "skip" - requirements: - - name: "__fusion_requirement_1" - dependsOn: "1" - selectionSet: "productById" - field: "id" - type: "ID!" - - """); - } - - [Test] - public void Skip_On_SubField_Resolved_From_Other_Source_Only_Skipped_Field_Selected_If_False() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name - reviews(first: 10) @skip(if: false) { - nodes { - body - } - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - id - } - } - - id: 2 - schema: "REVIEWS" - operation: >- - query($__fusion_requirement_1: ID!) { - productById(id: $__fusion_requirement_1) { - reviews(first: 10) { - nodes { - body - } - } - } - } - requirements: - - name: "__fusion_requirement_1" - dependsOn: "1" - selectionSet: "productById" - field: "id" - type: "ID!" - - """); - } - - [Test] - public void Skip_On_SubField_Resolved_From_Other_Source_Only_Skipped_Field_Selected_If_True() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) { - name - reviews(first: 10) @skip(if: true) { - nodes { - body - } - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - } - } - - """); - } - - [Test] - public void Skip_On_RootField() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!) { - productById(id: $id) @skip(if: $skip) { - name - } - products { - nodes { - name - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!, $skip: Boolean!) { - productById(id: $id) @skip(if: $skip) { - name - } - products { - nodes { - name - } - } - } - - """); - } - - [Test] - public void Skip_On_RootField_If_False() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) @skip(if: false) { - name - } - products { - nodes { - name - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - } - products { - nodes { - name - } - } - } - - """); - } - - [Test] - public void Skip_On_RootField_If_True() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) @skip(if: true) { - name - } - products { - nodes { - name - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - { - products { - nodes { - name - } - } - } - - """); - } - - [Test] - public void Skip_On_RootField_Only_Skipped_Field_Selected() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!) { - productById(id: $id) @skip(if: $skip) { - name - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - } - } - skipIf: "skip" - - """); - } - - [Test] - public void Skip_On_RootField_Only_Skipped_Field_Selected_If_False() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) @skip(if: false) { - name - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - } - } - - """); - } - - [Test] - public void Skip_On_RootField_Only_Skipped_Field_Selected_If_True() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!) { - productById(id: $id) @skip(if: true) { - name - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - """); - } - - [Test] - public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!, $include: Boolean!) { - productById(id: $id) @skip(if: $skip) @include(if: $include) { - name - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!) { - productById(id: $id) { - name - } - } - skipIf: "skip" - - """); - } - - [Test] - public void Skip_And_Include_On_RootField() - { - // arrange - var compositeSchema = CreateCompositeSchema(); - - // act - var plan = PlanOperationAsync( - compositeSchema, - """ - query GetProduct($id: ID!, $skip: Boolean!, $include: Boolean!) { - productById(id: $id) @skip(if: $skip) @include(if: $include) { - name - } - products { - nodes { - name - } - } - } - """); - - // assert - plan.ToYaml().MatchInlineSnapshot( - """ - nodes: - - id: 1 - schema: "PRODUCTS" - operation: >- - query($id: ID!, $include: Boolean!, $skip: Boolean!) { - productById(id: $id) @skip(if: $skip) @include(if: $include) { - name - } - products { - nodes { - name - } - } - } - - """); - } -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipAndIncludeTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipAndIncludeTests.cs new file mode 100644 index 00000000000..17b55975d5f --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipAndIncludeTests.cs @@ -0,0 +1,758 @@ +using static HotChocolate.Language.Utf8GraphQLParser; + +namespace HotChocolate.Fusion; + +public class SkipAndIncludeTests : FusionTestBase +{ + [Test] + public void Skip_And_Include_On_RootField() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) @include(if: $include) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_With_Same_Variable() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skipOrInclude) @include(if: $skipOrInclude) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Skip_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: false) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Skip_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: true) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Skip_True_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: false) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Skip_False_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: true) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Skip_True_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: true) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Skip_False_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: false) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) @include(if: $include) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_With_Same_Variable() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skipOrInclude) @include(if: $skipOrInclude) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: false) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: true) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: false) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: true) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: true) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: false) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) @include(if: $include) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_With_Same_Variable() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skipOrInclude) @include(if: $skipOrInclude) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Skip_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: false) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Skip_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: true) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Skip_True_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: false) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Skip_False_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: true) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Skip_True_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: true) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Skip_False_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: false) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) @include(if: $include) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: false) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: true) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_With_Same_Variable() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skipOrInclude) @include(if: $skipOrInclude) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: false) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: true) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: true) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_False() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: false) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipTests.cs new file mode 100644 index 00000000000..0be062b6764 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/SkipTests.cs @@ -0,0 +1,644 @@ +using static HotChocolate.Language.Utf8GraphQLParser; + +namespace HotChocolate.Fusion; + +public class SkipTests : FusionTestBase +{ + [Test] + public void Skipped_Root_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Root_Selection_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Root_Selections_From_Same_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip1: Boolean!, $skip2: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip1) { + name + } + products @skip(if: $skip2) { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Root_Selections_From_Same_Subgraph_Same_Variable() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + products @skip(if: $skip) { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Skipped_Root_Selections_From_Different_Subgraphs() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip1: Boolean!, $skip2: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip1) { + name + } + viewer @skip(if: $skip2) { + displayName + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Skipped_Root_Selections_From_Different_Subgraphs_Same_Variable() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + viewer @skip(if: $skip) { + displayName + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Skipped_Shared_Viewer_Root_Selection_With_Sub_Selections_From_Different_Subgraphs() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($skip: Boolean!) { + viewer @skip(if: $skip) { + displayName + reviews(first: 3) { + nodes { + body + } + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Skipped_Shared_byId_Root_Selection_With_Sub_Selections_From_Different_Subgraphs() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($id: ID!) { + productById(id: $id) @skip(if: $skip) { + name + averageRating + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) { + name + } + products { + nodes { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + viewer { + displayName + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Different_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) { + name + } + viewer { + displayName + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) + description + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + averageRating + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) + averageRating + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + averageRating @skip(if: $skip) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_From_Different_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + averageRating @skip(if: true) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name + averageRating @skip(if: $skip) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + averageRating @skip(if: true) + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + averageRating @skip(if: $skip) + reviews(first: 10) { + nodes { + body + } + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + averageRating @skip(if: true) + reviews(first: 10) { + nodes { + body + } + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($id: ID!, $skip: Boolean!) { + reviewById(id: $id) { + body + author @skip(if: $skip) { + displayName + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph_If_True() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($id: ID!) { + reviewById(id: $id) { + body + author @skip(if: true) { + displayName + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField.yaml new file mode 100644 index 00000000000..a9ab0fea2a2 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) @include(if: $include) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($include: Boolean!, $skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) @skip(if: $skip) @include(if: $include) { + name + } + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected.yaml new file mode 100644 index 00000000000..e3af3e0e5d2 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) @include(if: $include) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } + skipIf: "skip" + includeIf: "include" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False.yaml new file mode 100644 index 00000000000..2d5b59e1705 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: false) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } + includeIf: "include" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_False.yaml new file mode 100644 index 00000000000..044ad6f773d --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_False.yaml @@ -0,0 +1,8 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: false) { + name + } + } +nodes: diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_True.yaml new file mode 100644 index 00000000000..a1421ab74e5 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_False_Include_True.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: true) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True.yaml new file mode 100644 index 00000000000..ca5e8cdfe88 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True.yaml @@ -0,0 +1,8 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: true) { + name + } + } +nodes: diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_False.yaml new file mode 100644 index 00000000000..270aaeacef7 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_False.yaml @@ -0,0 +1,8 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: false) { + name + } + } +nodes: diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_True.yaml new file mode 100644 index 00000000000..7a2ddf86594 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_Skip_True_Include_True.yaml @@ -0,0 +1,8 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: true) { + name + } + } +nodes: diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_With_Same_Variable.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_With_Same_Variable.yaml new file mode 100644 index 00000000000..2b132a923bb --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Only_Skipped_Field_Selected_With_Same_Variable.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skipOrInclude) @include(if: $skipOrInclude) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } + skipIf: "skipOrInclude" + includeIf: "skipOrInclude" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False.yaml new file mode 100644 index 00000000000..2b782e87f29 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: false) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($include: Boolean!, $slug: String!) { + productBySlug(slug: $slug) @include(if: $include) { + name + } + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False_Include_False.yaml new file mode 100644 index 00000000000..bb3ea8107be --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False_Include_False.yaml @@ -0,0 +1,23 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: false) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + { + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False_Include_True.yaml new file mode 100644 index 00000000000..5506a5d00f2 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_False_Include_True.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: false) @include(if: true) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True.yaml new file mode 100644 index 00000000000..c4359a9c74f --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True.yaml @@ -0,0 +1,23 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) @include(if: $include) @skip(if: true) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + { + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True_Include_False.yaml new file mode 100644 index 00000000000..8f3041ed42a --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True_Include_False.yaml @@ -0,0 +1,23 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: false) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + { + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True_Include_True.yaml new file mode 100644 index 00000000000..ad15299b54a --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_Skip_True_Include_True.yaml @@ -0,0 +1,23 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) @include(if: true) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + { + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_With_Same_Variable.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_With_Same_Variable.yaml new file mode 100644 index 00000000000..0839197c588 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_RootField_With_Same_Variable.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skipOrInclude) @include(if: $skipOrInclude) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skipOrInclude: Boolean!, $slug: String!) { + productBySlug(slug: $slug) @skip(if: $skipOrInclude) @include(if: $skipOrInclude) { + name + } + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField.yaml new file mode 100644 index 00000000000..b102a345e00 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) @include(if: $include) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($include: Boolean!, $skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) @include(if: $include) + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected.yaml new file mode 100644 index 00000000000..ac79de007a9 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!, $skip: Boolean!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) @include(if: $include) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($include: Boolean!, $skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) @include(if: $include) + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False.yaml new file mode 100644 index 00000000000..5eae9b5ec13 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: false) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($include: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @include(if: $include) + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_False.yaml new file mode 100644 index 00000000000..5681444feb2 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_False.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: false) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_True.yaml new file mode 100644 index 00000000000..42ca103abe1 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_False_Include_True.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: true) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True.yaml new file mode 100644 index 00000000000..f5376ac45a5 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: true) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_False.yaml new file mode 100644 index 00000000000..dba8c52cd78 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_False.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: false) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_True.yaml new file mode 100644 index 00000000000..680250937db --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_Skip_True_Include_True.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: true) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_With_Same_Variable.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_With_Same_Variable.yaml new file mode 100644 index 00000000000..29c30a28571 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Only_Skipped_Field_Selected_With_Same_Variable.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skipOrInclude) @include(if: $skipOrInclude) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skipOrInclude: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skipOrInclude) @include(if: $skipOrInclude) + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False.yaml new file mode 100644 index 00000000000..ee167dbf363 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: false) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($include: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @include(if: $include) + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False_Include_False.yaml new file mode 100644 index 00000000000..ba370985959 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False_Include_False.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: false) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False_Include_True.yaml new file mode 100644 index 00000000000..4a2d32db899 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_False_Include_True.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: false) @include(if: true) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True.yaml new file mode 100644 index 00000000000..4b8a9e6a21e --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query GetProduct($slug: String!, $include: Boolean!) { + productBySlug(slug: $slug) { + name @include(if: $include) @skip(if: true) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True_Include_False.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True_Include_False.yaml new file mode 100644 index 00000000000..875b30e0a4d --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True_Include_False.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: false) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True_Include_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True_Include_True.yaml new file mode 100644 index 00000000000..cac07f127cf --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_Skip_True_Include_True.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query GetProduct($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) @include(if: true) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_With_Same_Variable.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_With_Same_Variable.yaml new file mode 100644 index 00000000000..031a6c9a7f0 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipAndIncludeTests.Skip_And_Include_On_SubField_With_Same_Variable.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query GetProduct($slug: String!, $skipOrInclude: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skipOrInclude) @include(if: $skipOrInclude) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skipOrInclude: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skipOrInclude) @include(if: $skipOrInclude) + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection.yaml new file mode 100644 index 00000000000..6b046c9e463 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } + skipIf: "skip" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_If_True.yaml new file mode 100644 index 00000000000..f46ba4401cb --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_If_True.yaml @@ -0,0 +1,8 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) { + name + } + } +nodes: diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph.yaml new file mode 100644 index 00000000000..f7a38be6130 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph_If_True.yaml new file mode 100644 index 00000000000..60e5da042e0 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selection_Other_Not_Skipped_Root_Selection_From_Same_Subgraph_If_True.yaml @@ -0,0 +1,23 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) @skip(if: true) { + name + } + products { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + { + products { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selections_From_Same_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selections_From_Same_Subgraph.yaml new file mode 100644 index 00000000000..f658cdd526c --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selections_From_Same_Subgraph.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query($slug: String!, $skip1: Boolean!, $skip2: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip1) { + name + } + products @skip(if: $skip2) { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skip1: Boolean!, $skip2: Boolean!, $slug: String!) { + productBySlug(slug: $slug) @skip(if: $skip1) { + name + } + products @skip(if: $skip2) { + nodes { + name + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selections_From_Same_Subgraph_Same_Variable.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selections_From_Same_Subgraph_Same_Variable.yaml new file mode 100644 index 00000000000..6540ffb3a21 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Root_Selections_From_Same_Subgraph_Same_Variable.yaml @@ -0,0 +1,27 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) @skip(if: $skip) { + name + } + products @skip(if: $skip) { + nodes { + name + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + products { + nodes { + name + } + } + } + skipIf: "skip" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection.yaml new file mode 100644 index 00000000000..a043447b011 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph.yaml new file mode 100644 index 00000000000..c591a85b267 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph.yaml @@ -0,0 +1,31 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + averageRating @skip(if: $skip) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + skipIf: "skip" + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_If_True.yaml new file mode 100644 index 00000000000..a288d2d747f --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_If_True.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + averageRating @skip(if: true) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph.yaml new file mode 100644 index 00000000000..562aa4923af --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph.yaml @@ -0,0 +1,33 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name + averageRating @skip(if: $skip) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + skipIf: "skip" + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph_If_True.yaml new file mode 100644 index 00000000000..16255157f03 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_First_Subgraph_If_True.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + averageRating @skip(if: true) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph.yaml new file mode 100644 index 00000000000..546cf4df2a0 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph.yaml @@ -0,0 +1,40 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + averageRating @skip(if: $skip) + reviews(first: 10) { + nodes { + body + } + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!, $skip: Boolean!) { + productById(id: $__fusion_requirement_1) { + averageRating @skip(if: $skip) + reviews(first: 10) { + nodes { + body + } + } + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True.yaml new file mode 100644 index 00000000000..dd948571a7c --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_From_Different_Subgraph_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True.yaml @@ -0,0 +1,40 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + averageRating @skip(if: true) + reviews(first: 10) { + nodes { + body + } + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + reviews(first: 10) { + nodes { + body + } + } + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_If_True.yaml new file mode 100644 index 00000000000..0ac1c60dc95 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_If_True.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph.yaml new file mode 100644 index 00000000000..bcc49f74a5c --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph.yaml @@ -0,0 +1,32 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + averageRating + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph_If_True.yaml new file mode 100644 index 00000000000..c248f8d61b3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Different_Subgraph_If_True.yaml @@ -0,0 +1,32 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) + averageRating + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + __typename + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph.yaml new file mode 100644 index 00000000000..a0523486f65 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query($slug: String!, $skip: Boolean!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($skip: Boolean!, $slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: $skip) + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True.yaml new file mode 100644 index 00000000000..43b57a780f7 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_Other_Not_Skipped_Sub_Selection_From_Same_Subgraph_If_True.yaml @@ -0,0 +1,17 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name @skip(if: true) + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph.yaml new file mode 100644 index 00000000000..eb2168bc3ce --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph.yaml @@ -0,0 +1,36 @@ +request: + - document: >- + query($id: ID!, $skip: Boolean!) { + reviewById(id: $id) { + body + author @skip(if: $skip) { + displayName + } + } + } +nodes: + - id: 1 + schema: "REVIEWS" + operation: >- + query($id: ID!, $skip: Boolean!) { + reviewById(id: $id) { + body + author @skip(if: $skip) { + id + } + } + } + - id: 2 + schema: "ACCOUNTS" + operation: >- + query($__fusion_requirement_1: ID!) { + userById(id: $__fusion_requirement_1) { + displayName + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "reviewById.author" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph_If_True.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph_If_True.yaml new file mode 100644 index 00000000000..3fed0dc8a0b --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/ConditionTests/__snapshots__/SkipTests.Skipped_Sub_Selection_That_Provides_Data_For_Lookup_On_Different_Subgraph_If_True.yaml @@ -0,0 +1,19 @@ +request: + - document: >- + query($id: ID!) { + reviewById(id: $id) { + body + author @skip(if: true) { + displayName + } + } + } +nodes: + - id: 1 + schema: "REVIEWS" + operation: >- + query($id: ID!) { + reviewById(id: $id) { + body + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FragmentTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FragmentTests.cs new file mode 100644 index 00000000000..03c1a8de6a9 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FragmentTests.cs @@ -0,0 +1,453 @@ +using static HotChocolate.Language.Utf8GraphQLParser; + +namespace HotChocolate.Fusion; + +public class FragmentTests : FusionTestBase +{ + [Test] + public void Fragment_On_Root() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + ...QueryFragment + } + + fragment QueryFragment on Query { + productBySlug(slug: $slug) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Root_Next_To_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + ...QueryFragment + } + + fragment QueryFragment on Query { + productBySlug(slug: $slug) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + ...QueryFragment + } + + fragment QueryFragment on Query { + productBySlug(slug: $slug) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Root_Next_To_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + products { + nodes { + description + } + } + ...QueryFragment + } + + fragment QueryFragment on Query { + productBySlug(slug: $slug) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Fragment_On_Root_Next_To_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + viewer { + displayName + } + ...QueryFragment + } + + fragment QueryFragment on Query { + productBySlug(slug: $slug) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Root_With_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + ...QueryFragment1 + ...QueryFragment2 + } + + fragment QueryFragment1 on Query { + productBySlug(slug: $slug) { + name + } + } + + fragment QueryFragment2 on Query { + productBySlug(slug: $slug) { + name + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Root_With_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + ...QueryFragment1 + ...QueryFragment2 + } + + fragment QueryFragment1 on Query { + productBySlug(slug: $slug) { + name + } + } + + fragment QueryFragment2 on Query { + products { + nodes { + description + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Two_Fragments_On_Root_With_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + ...QueryFragment1 + ...QueryFragment2 + } + + fragment QueryFragment1 on Query { + productBySlug(slug: $slug) { + name + } + } + + fragment QueryFragment2 on Query { + viewer { + displayName + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Sub_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ...ProductFragment + } + } + + fragment ProductFragment on Product { + name + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Sub_Selection_Next_To_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + ...ProductFragment + } + } + + fragment ProductFragment on Product { + name + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Sub_Selection_Next_To_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + ...ProductFragment + } + } + + fragment ProductFragment on Product { + description + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Fragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + ...ProductFragment + } + } + + fragment ProductFragment on Product { + averageRating + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Sub_Selection_With_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ...ProductFragment1 + ...ProductFragment2 + } + } + + fragment ProductFragment1 on Product { + name + } + + fragment ProductFragment2 on Product { + name + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Sub_Selection_With_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ...ProductFragment1 + ...ProductFragment2 + } + } + + fragment ProductFragment1 on Product { + name + } + + fragment ProductFragment2 on Product { + description + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ...ProductFragment1 + ...ProductFragment2 + } + } + + fragment ProductFragment1 on Product { + name + } + + fragment ProductFragment2 on Product { + averageRating + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FusionTestBase.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FusionTestBase.cs index 0764abfde12..71631911fee 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FusionTestBase.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/FusionTestBase.cs @@ -14,12 +14,10 @@ protected static CompositeSchema CreateCompositeSchema() return CompositeSchemaBuilder.Create(compositeSchemaDoc); } - protected static RequestPlanNode PlanOperationAsync(CompositeSchema compositeSchema, string operation) + protected static RequestPlanNode PlanOperation(DocumentNode request, CompositeSchema compositeSchema) { - var doc = Utf8GraphQLParser.Parse(operation); - var rewriter = new InlineFragmentOperationRewriter(compositeSchema); - var rewritten = rewriter.RewriteDocument(doc, null); + var rewritten = rewriter.RewriteDocument(request, null); var planner = new OperationPlanner(compositeSchema); return planner.CreatePlan(rewritten, null); diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/InlineFragmentTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/InlineFragmentTests.cs new file mode 100644 index 00000000000..493d96b2a9b --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/InlineFragmentTests.cs @@ -0,0 +1,411 @@ +using HotChocolate.Language; + +namespace HotChocolate.Fusion; + +public class InlineFragmentTests : FusionTestBase +{ + [Test] + public void InlineFragment_On_Root() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + ... { + productBySlug(slug: $slug) { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Root_Next_To_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + ... { + productBySlug(slug: $slug) { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + ... { + productBySlug(slug: $slug) { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Root_Next_To_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + products { + nodes { + description + } + } + ... { + productBySlug(slug: $slug) { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void InlineFragment_On_Root_Next_To_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + viewer { + displayName + } + ... { + productBySlug(slug: $slug) { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_InlineFragments_On_Root_With_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + ... { + productBySlug(slug: $slug) { + name + } + } + ... { + productBySlug(slug: $slug) { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_InlineFragments_On_Root_With_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + ... { + productBySlug(slug: $slug) { + name + } + } + ... { + products { + nodes { + description + } + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + [Skip("Not yet supported by the planner")] + public void Two_InlineFragments_On_Root_With_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + ... { + productBySlug(slug: $slug) { + name + } + } + ... { + viewer { + displayName + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Sub_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ... { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Sub_Selection_Next_To_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + ... { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Sub_Selection_Next_To_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + ... { + description + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void InlineFragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + name + ... { + averageRating + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Sub_Selection_With_Same_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ... { + name + } + ... { + name + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Sub_Selection_With_Different_Selection() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ... { + name + } + ... { + description + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } + + [Test] + public void Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph() + { + // arrange + var compositeSchema = CreateCompositeSchema(); + + var request = Utf8GraphQLParser.Parse( + """ + query($slug: String!) { + productBySlug(slug: $slug) { + ... { + name + } + ... { + averageRating + } + } + } + """); + + // act + var plan = PlanOperation(request, compositeSchema); + + // assert + plan.MatchSnapshot(); + } +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/OperationPlannerTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/OperationPlannerTests.cs index 4469fb5c31a..3a5de8f4dc8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/OperationPlannerTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/OperationPlannerTests.cs @@ -1,6 +1,7 @@ using HotChocolate.Fusion.Planning; using HotChocolate.Fusion.Types.Completion; using HotChocolate.Language; +using static HotChocolate.Language.Utf8GraphQLParser; namespace HotChocolate.Fusion; @@ -12,12 +13,10 @@ public void Plan_Simple_Operation_1_Source_Schema() // arrange var compositeSchema = CreateCompositeSchema(); - // act - var plan = PlanOperationAsync( - compositeSchema, + var request = Parse( """ { - productById(id: 1) { + productBySlug(slug: "1") { ... Product } } @@ -28,6 +27,9 @@ fragment Product on Product { } """); + // act + var plan = PlanOperation(request, compositeSchema); + // assert plan.MatchSnapshot(); } @@ -38,12 +40,10 @@ public void Plan_Simple_Operation_2_Source_Schema() // arrange var compositeSchema = CreateCompositeSchema(); - // act - var plan = PlanOperationAsync( - compositeSchema, + var request = Parse( """ { - productById(id: 1) { + productBySlug(slug: "1") { ... Product } } @@ -55,6 +55,9 @@ fragment Product on Product { } """); + // act + var plan = PlanOperation(request, compositeSchema); + // assert plan.MatchSnapshot(); } @@ -65,12 +68,10 @@ public void Plan_Simple_Operation_3_Source_Schema() // arrange var compositeSchema = CreateCompositeSchema(); - // act - var plan = PlanOperationAsync( - compositeSchema, + var request = Parse( """ { - productById(id: 1) { + productBySlug(slug: "1") { ... ProductCard } } @@ -97,6 +98,9 @@ fragment AuthorCard on UserProfile { } """); + // act + var plan = PlanOperation(request, compositeSchema); + // assert plan.MatchSnapshot(); } @@ -107,12 +111,10 @@ public void Plan_Simple_Operation_3_Source_Schema_And_Single_Variable() // arrange var compositeSchema = CreateCompositeSchema(); - // act - var plan = PlanOperationAsync( - compositeSchema, + var request = Parse( """ - query GetProduct($id: ID!, $first: Int! = 10) { - productById(id: $id) { + query GetProduct($slug: String! $first: Int! = 10) { + productBySlug(slug: $slug) { ... ProductCard } } @@ -139,6 +141,9 @@ fragment AuthorCard on UserProfile { } """); + // act + var plan = PlanOperation(request, compositeSchema); + // assert plan.MatchSnapshot(); } @@ -146,10 +151,10 @@ fragment AuthorCard on UserProfile { [Test] public void Plan_With_Conditional_InlineFragment() { - var compositeSchemaDoc = Utf8GraphQLParser.Parse(FileResource.Open("fusion1.graphql")); - var compositeSchema = CompositeSchemaBuilder.Create(compositeSchemaDoc); + // arrange + var compositeSchema = CreateCompositeSchema(); - var doc = Utf8GraphQLParser.Parse( + var request = Parse( """ { productById(id: 1) { @@ -166,12 +171,8 @@ ... @include(if: true) { } """); - var rewriter = new InlineFragmentOperationRewriter(compositeSchema); - var rewritten = rewriter.RewriteDocument(doc, null); - // act - var planner = new OperationPlanner(compositeSchema); - var plan = planner.CreatePlan(rewritten, null); + var plan = PlanOperation(request, compositeSchema); // assert plan.MatchSnapshot(); diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__resources__/fusion1.graphql b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__resources__/fusion1.graphql index 81047170eb2..b28a3b8736c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__resources__/fusion1.graphql +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__resources__/fusion1.graphql @@ -1,12 +1,27 @@ type Query @fusion__type(schema: ACCOUNTS) + @fusion__type(schema: REVIEWS) @fusion__type(schema: PRODUCTS) { - viewer: UserProfile + viewer: Viewer @fusion__field(schema: ACCOUNTS) + @fusion__field(schema: REVIEWS) productById(id: ID!): Product @fusion__field(schema: PRODUCTS) products(first: Int, after: String, last: Int, before: String): ProductConnection @fusion__field(schema: PRODUCTS) + productBySlug(slug: String!): Product + @fusion__field(schema: PRODUCTS) + reviewById(id: ID!): Review + @fusion__field(schema: REVIEWS) +} + +type Viewer + @fusion__type(schema: ACCOUNTS) + @fusion__type(schema: REVIEWS) { + displayName: String! + @fusion__field(schema: ACCOUNTS) + reviews(first: Int, after: String, last: Int, before: String): ProductReviewConnection + @fusion__field(schema: REVIEWS) } type Product diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Different_Selection.yaml new file mode 100644 index 00000000000..fa618f888e9 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Different_Selection.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query($slug: String!) { + products { + nodes { + description + } + } + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + products { + nodes { + description + } + } + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection.yaml new file mode 100644 index 00000000000..cd38e02de77 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection.yaml @@ -0,0 +1,22 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Different_Selection.yaml new file mode 100644 index 00000000000..55b3b188610 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Different_Selection.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph.yaml new file mode 100644 index 00000000000..9b40214e86e --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph.yaml @@ -0,0 +1,32 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + averageRating + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Fragment_On_Sub_Selection_Next_To_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Root_With_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Root_With_Different_Selection.yaml new file mode 100644 index 00000000000..32937ed0c11 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Root_With_Different_Selection.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + products { + nodes { + description + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + products { + nodes { + description + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Root_With_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Root_With_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Root_With_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection.yaml new file mode 100644 index 00000000000..55b3b188610 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph.yaml new file mode 100644 index 00000000000..9b40214e86e --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph.yaml @@ -0,0 +1,32 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + averageRating + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/FragmentTests.Two_Fragments_On_Sub_Selection_With_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Different_Selection.yaml new file mode 100644 index 00000000000..fa618f888e9 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Different_Selection.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query($slug: String!) { + products { + nodes { + description + } + } + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + products { + nodes { + description + } + } + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection.yaml new file mode 100644 index 00000000000..cd38e02de77 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Root_Next_To_Same_Selection_With_Different_Sub_Selection.yaml @@ -0,0 +1,22 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + description + } + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Different_Selection.yaml new file mode 100644 index 00000000000..55b3b188610 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Different_Selection.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph.yaml new file mode 100644 index 00000000000..9b40214e86e --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Different_Selection_From_Different_Subgraph.yaml @@ -0,0 +1,32 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + averageRating + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.InlineFragment_On_Sub_Selection_Next_To_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection.yaml new file mode 100644 index 00000000000..55b3b188610 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection.yaml @@ -0,0 +1,18 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + description + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph.yaml new file mode 100644 index 00000000000..9b40214e86e --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Different_Selection_From_Different_Subgraph.yaml @@ -0,0 +1,32 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + averageRating + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + id + } + } + - id: 2 + schema: "REVIEWS" + operation: >- + query($__fusion_requirement_1: ID!) { + productById(id: $__fusion_requirement_1) { + averageRating + } + } + requirements: + - name: "__fusion_requirement_1" + dependsOn: "1" + selectionSet: "productBySlug" + field: "id" + type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_Fragments_On_Sub_Selection_With_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_InlineFragments_On_Root_With_Different_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_InlineFragments_On_Root_With_Different_Selection.yaml new file mode 100644 index 00000000000..32937ed0c11 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_InlineFragments_On_Root_With_Different_Selection.yaml @@ -0,0 +1,26 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + products { + nodes { + description + } + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + products { + nodes { + description + } + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_InlineFragments_On_Root_With_Same_Selection.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_InlineFragments_On_Root_With_Same_Selection.yaml new file mode 100644 index 00000000000..05c64db41f3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/InlineFragmentTests.Two_InlineFragments_On_Root_With_Same_Selection.yaml @@ -0,0 +1,16 @@ +request: + - document: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } +nodes: + - id: 1 + schema: "PRODUCTS" + operation: >- + query($slug: String!) { + productBySlug(slug: $slug) { + name + } + } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_1_Source_Schema.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_1_Source_Schema.yaml index fa94aa6d5b9..b1d8c35fc7a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_1_Source_Schema.yaml +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_1_Source_Schema.yaml @@ -1,7 +1,7 @@ request: - document: >- { - productById(id: 1) { + productBySlug(slug: "1") { id name } @@ -11,7 +11,7 @@ nodes: schema: "PRODUCTS" operation: >- { - productById(id: 1) { + productBySlug(slug: "1") { id name } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_2_Source_Schema.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_2_Source_Schema.yaml index fb627248a54..b1b4dfa8bc8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_2_Source_Schema.yaml +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_2_Source_Schema.yaml @@ -1,7 +1,7 @@ request: - document: >- { - productById(id: 1) { + productBySlug(slug: "1") { id name estimatedDelivery(postCode: "12345") @@ -12,7 +12,7 @@ nodes: schema: "PRODUCTS" operation: >- { - productById(id: 1) { + productBySlug(slug: "1") { id name id @@ -29,6 +29,6 @@ nodes: requirements: - name: "__fusion_requirement_1" dependsOn: "1" - selectionSet: "productById" + selectionSet: "productBySlug" field: "id" type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema.yaml index 564b497ae66..5f080b9b42f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema.yaml +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema.yaml @@ -1,7 +1,7 @@ request: - document: >- { - productById(id: 1) { + productBySlug(slug: "1") { name reviews(first: 10) { nodes { @@ -19,7 +19,7 @@ nodes: schema: "PRODUCTS" operation: >- { - productById(id: 1) { + productBySlug(slug: "1") { name id } @@ -43,7 +43,7 @@ nodes: requirements: - name: "__fusion_requirement_2" dependsOn: "1" - selectionSet: "productById" + selectionSet: "productBySlug" field: "id" type: "ID!" - id: 3 @@ -57,6 +57,6 @@ nodes: requirements: - name: "__fusion_requirement_1" dependsOn: "2" - selectionSet: "productById.reviews.nodes.author" + selectionSet: "productBySlug.reviews.nodes.author" field: "id" type: "ID!" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema_And_Single_Variable.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema_And_Single_Variable.yaml index 5d180c3fe59..a0357984006 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema_And_Single_Variable.yaml +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/__snapshots__/OperationPlannerTests.Plan_Simple_Operation_3_Source_Schema_And_Single_Variable.yaml @@ -1,7 +1,7 @@ request: - document: >- - query GetProduct($id: ID!, $first: Int! = 10) { - productById(id: $id) { + query GetProduct($slug: String!, $first: Int! = 10) { + productBySlug(slug: $slug) { name reviews(first: $first) { nodes { @@ -18,8 +18,8 @@ nodes: - id: 1 schema: "PRODUCTS" operation: >- - query($id: ID!) { - productById(id: $id) { + query($slug: String!) { + productBySlug(slug: $slug) { name id } @@ -43,7 +43,7 @@ nodes: requirements: - name: "__fusion_requirement_2" dependsOn: "1" - selectionSet: "productById" + selectionSet: "productBySlug" field: "id" type: "ID!" - id: 3 @@ -57,6 +57,6 @@ nodes: requirements: - name: "__fusion_requirement_1" dependsOn: "2" - selectionSet: "productById.reviews.nodes.author" + selectionSet: "productBySlug.reviews.nodes.author" field: "id" type: "ID!"