Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fusion vNext] Add support for @skip / @include on fragments #7808

Merged
merged 11 commits into from
Dec 13, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace HotChocolate.Fusion.Planning;

// TODO: We need to merge selections
public sealed class InlineFragmentOperationRewriter(CompositeSchema schema)
{
public DocumentNode RewriteDocument(DocumentNode document, string? operationName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ public sealed class InlineFragmentPlanNode : SelectionPlanNode
public InlineFragmentPlanNode(
ICompositeNamedType declaringType,
InlineFragmentNode inlineFragment)
: this(declaringType, inlineFragment.SelectionSet.Selections)
: this(declaringType, inlineFragment.Directives, inlineFragment.SelectionSet.Selections)
{
}

public InlineFragmentPlanNode(
ICompositeNamedType declaringType,
IReadOnlyList<DirectiveNode> directiveNodes,
IReadOnlyList<ISelectionNode> selectionNodes)
: base(declaringType, [], selectionNodes)
: base(declaringType, directiveNodes, selectionNodes)
{
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ private static void CollectAndBindUsedVariables(
usedVariables.Add(variable.Name.Value);
}
}
}

foreach (var directive in field.Directives)
foreach (var directive in node.Directives)
{
foreach (var argument in directive.Arguments)
{
foreach (var argument in directive.Arguments)
if (argument.Value is VariableNode variable)
{
if (argument.Value is VariableNode variable)
{
usedVariables.Add(variable.Name.Value);
}
usedVariables.Add(variable.Name.Value);
}
}
}
Expand All @@ -67,7 +67,7 @@ private static void CollectAndBindUsedVariables(

foreach (var variable in usedVariables)
{
if(variableDefinitions.TryGetValue(variable, out var variableDefinition))
if (variableDefinitions.TryGetValue(variable, out var variableDefinition))
{
operation.AddVariableDefinition(variableDefinition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace HotChocolate.Fusion;

// TODO: Test shared skip selection with one selection having an include - should fail today incorrectly!
public class SkipAndIncludeTests : FusionTestBase
{
[Test]
Expand Down
Loading
Loading