-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into gai/cookie-crumble-xunit-v3
- Loading branch information
Showing
23 changed files
with
863 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/MergeSelectionSetRewriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using HotChocolate.Fusion.Types; | ||
using HotChocolate.Language; | ||
|
||
namespace HotChocolate.Fusion.Planning; | ||
|
||
public class MergeSelectionSetRewriter(CompositeSchema schema) | ||
{ | ||
private readonly InlineFragmentOperationRewriter _rewriter = new(schema); | ||
|
||
public SelectionSetNode RewriteSelectionSets( | ||
IReadOnlyList<SelectionSetNode> selectionSets, | ||
ICompositeNamedType type) | ||
{ | ||
var context = new InlineFragmentOperationRewriter.Context( | ||
type, | ||
new Dictionary<string, FragmentDefinitionNode>()); | ||
|
||
var merged = new SelectionSetNode( | ||
null, | ||
selectionSets.SelectMany(t => t.Selections).ToList()); | ||
|
||
_rewriter.CollectSelections(merged, context); | ||
_rewriter.RewriteSelections(context); | ||
|
||
return new SelectionSetNode( | ||
null, | ||
context.Selections.ToImmutable()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.