Skip to content

Commit

Permalink
[Fusion] Fix explosion of selections (#8030)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-tengler authored Feb 18, 2025
1 parent d51cb83 commit 3928221
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ public Config(
IReadOnlyList<string> path,
TransportFeatures transportFeatures)
{
// This is a temporary solution to selections being duplicated during request planning.
// It should be properly fixed with new planner in the future.
var rewriter = new SelectionRewriter();
document = rewriter.RewriteDocument(document, null);

string[]? buffer = null;
var usedCapacity = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,37 +256,34 @@ protected virtual void AddSelectionNode(
? new NameNode(selection.ResponseName)
: null;

// TODO: this is not good but will fix the include issue ...
// we need to rework the operation compiler for a proper fix.
foreach (var node in selection.SyntaxNodes)
var syntaxNode = selection.SyntaxNode;

if (syntaxNode.Directives.Count > 0)
{
if(node.Directives.Count > 0)
foreach (var directive in syntaxNode.Directives)
{
foreach (var directive in node.Directives)
foreach (var argument in directive.Arguments)
{
foreach (var argument in directive.Arguments)
if (argument.Value is not VariableNode variable)
{
if (argument.Value is not VariableNode variable)
{
continue;
}

var originalVarDef = context.Operation.Definition.VariableDefinitions
.First(t => t.Variable.Equals(variable, SyntaxComparison.Syntax));
context.ForwardedVariables.Add(originalVarDef);
continue;
}

var originalVarDef = context.Operation.Definition.VariableDefinitions
.First(t => t.Variable.Equals(variable, SyntaxComparison.Syntax));
context.ForwardedVariables.Add(originalVarDef);
}
}

selectionNodes.Add(
new FieldNode(
null,
new(binding.Name),
alias,
node.Directives,
node.Arguments,
selectionSetNode));
}

selectionNodes.Add(
new FieldNode(
null,
new(binding.Name),
alias,
syntaxNode.Directives,
syntaxNode.Arguments,
selectionSetNode));
}

protected virtual SelectionSetNode CreateSelectionSetNode(
Expand Down
169 changes: 0 additions & 169 deletions src/HotChocolate/Fusion/src/Core/Utilities/SelectionRewriter.cs

This file was deleted.

0 comments on commit 3928221

Please sign in to comment.