Skip to content

Commit

Permalink
Added Fusion 15 base project structure. (#7743)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Nov 20, 2024
1 parent 2493c90 commit b521e35
Show file tree
Hide file tree
Showing 96 changed files with 952 additions and 283 deletions.
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<PackageVersion Include="System.Reactive" Version="6.0.0" />
<PackageVersion Include="Xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="TUnit" Version="0.3.34" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
Expand Down
4 changes: 4 additions & 0 deletions src/HotChocolate/Fusion-vnext/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />

</Project>
50 changes: 50 additions & 0 deletions src/HotChocolate/Fusion-vnext/HotChocolate.Fusion-vnext.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1718E238-A6E5-42AE-A2D6-A0580457D486}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Fusion.Execution", "src\Fusion.Execution\HotChocolate.Fusion.Execution.csproj", "{1566D098-4146-4ECF-9F45-EA43D88EEAA9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F7DA6A87-1AFE-479A-B138-96C32439ABF5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Fusion.Execution.Tests", "test\Fusion.Execution.Tests\HotChocolate.Fusion.Execution.Tests.csproj", "{51749890-1860-46CD-B872-3E790C44A876}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Fusion.Composition", "src\Fusion.Composition\HotChocolate.Fusion.Composition.csproj", "{6524E2C7-12A0-4987-B146-46C077B46DC0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Fusion.Composition.Tests", "test\Fusion.Composition.Tests\HotChocolate.Fusion.Composition.Tests.csproj", "{1B0E0209-A99B-4AA4-95DD-30828C9CB5A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1566D098-4146-4ECF-9F45-EA43D88EEAA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1566D098-4146-4ECF-9F45-EA43D88EEAA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1566D098-4146-4ECF-9F45-EA43D88EEAA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1566D098-4146-4ECF-9F45-EA43D88EEAA9}.Release|Any CPU.Build.0 = Release|Any CPU
{51749890-1860-46CD-B872-3E790C44A876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51749890-1860-46CD-B872-3E790C44A876}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51749890-1860-46CD-B872-3E790C44A876}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51749890-1860-46CD-B872-3E790C44A876}.Release|Any CPU.Build.0 = Release|Any CPU
{6524E2C7-12A0-4987-B146-46C077B46DC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6524E2C7-12A0-4987-B146-46C077B46DC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6524E2C7-12A0-4987-B146-46C077B46DC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6524E2C7-12A0-4987-B146-46C077B46DC0}.Release|Any CPU.Build.0 = Release|Any CPU
{1B0E0209-A99B-4AA4-95DD-30828C9CB5A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B0E0209-A99B-4AA4-95DD-30828C9CB5A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B0E0209-A99B-4AA4-95DD-30828C9CB5A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B0E0209-A99B-4AA4-95DD-30828C9CB5A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1566D098-4146-4ECF-9F45-EA43D88EEAA9} = {1718E238-A6E5-42AE-A2D6-A0580457D486}
{51749890-1860-46CD-B872-3E790C44A876} = {F7DA6A87-1AFE-479A-B138-96C32439ABF5}
{6524E2C7-12A0-4987-B146-46C077B46DC0} = {1718E238-A6E5-42AE-A2D6-A0580457D486}
{1B0E0209-A99B-4AA4-95DD-30828C9CB5A9} = {F7DA6A87-1AFE-479A-B138-96C32439ABF5}
EndGlobalSection
EndGlobal
15 changes: 15 additions & 0 deletions src/HotChocolate/Fusion-vnext/src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove('Nullable.props', '$(MSBuildThisFileDirectory)..\'))" />

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);CA1812</NoWarn>
</PropertyGroup>

<PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>HotChocolate.Fusion.Composition.Tests</AssemblyName>
<RootNamespace>HotChocolate.Composition</RootNamespace>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>HotChocolate.Fusion.Planning</AssemblyName>
<AssemblyName>HotChocolate.Fusion.Execution</AssemblyName>
<RootNamespace>HotChocolate.Fusion</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using HotChocolate.Language;

namespace HotChocolate.Fusion.Planning;

public interface IOperationNode
{
ISyntaxNode ToSyntaxNode();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using HotChocolate.Fusion.Types.Collections;
using HotChocolate.Language;

namespace HotChocolate.Fusion.Planning;

public interface ISelection : IOperationNode
{
SelectionSet? SelectionSet { get; }

DirectiveCollection Directives { get; }

new ISelectionNode ToSyntaxNode();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using HotChocolate.Fusion.Types;
using HotChocolate.Fusion.Types.Collections;
using HotChocolate.Language;

namespace HotChocolate.Fusion.Planning;

public sealed class InlineFragment : ISelection
{
public InlineFragment(
ICompositeNamedType type,
DirectiveCollection directives,
SelectionSet selectionSet)
{
Type = type;
Directives = directives;
SelectionSet = selectionSet;
}

public ICompositeNamedType Type { get; }

public DirectiveCollection Directives { get; }


public SelectionSet SelectionSet { get; }

public InlineFragmentNode ToSyntaxNode()
{
return new InlineFragmentNode(
null,
new NamedTypeNode(new NameNode(Type.Name)),
Directives.ToSyntaxNodes(),
SelectionSet.ToSyntaxNode());
}

ISelectionNode ISelection.ToSyntaxNode()
=> ToSyntaxNode();

ISyntaxNode IOperationNode.ToSyntaxNode()
=> ToSyntaxNode();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using HotChocolate.Fusion.Types;
using HotChocolate.Language;

namespace HotChocolate.Fusion.Planning;

public class FieldPlanNode : SelectionPlanNode
{
public FieldPlanNode(
FieldNode fieldNode,
CompositeOutputField field)
: base(field.Type.NamedType(), fieldNode.SelectionSet?.Selections)
{
FieldNode = fieldNode;
Field = field;
ResponseName = FieldNode.Alias?.Value ?? field.Name;
}

public string ResponseName { get; }

public FieldNode FieldNode { get; }

public CompositeOutputField Field { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace HotChocolate.Fusion.Planning;

public interface IOperationPlanNodeProvider
{
public IReadOnlyList<OperationPlanNode> Operations { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using HotChocolate.Fusion.Types;
using HotChocolate.Language;

namespace HotChocolate.Fusion.Planning;

/// <summary>
/// Represents an operation to resolve data from a specific source schema.
/// </summary>
public sealed class OperationPlanNode : SelectionPlanNode, IOperationPlanNodeProvider
{
private List<OperationPlanNode>? _operations;

public OperationPlanNode(
string schemaName,
ICompositeNamedType declaringType,
SelectionSetNode selectionSet,
PlanNode? parent = null)
: base(declaringType, selectionSet.Selections)
{
SchemaName = schemaName;
Parent = parent;
}

public OperationPlanNode(
string schemaName,
ICompositeNamedType declaringType,
IReadOnlyList<ISelectionNode> selections,
PlanNode? parent = null)
: base(declaringType, selections)
{
SchemaName = schemaName;
Parent = parent;
}

public string SchemaName { get; }

public IReadOnlyList<OperationPlanNode> Operations
=> _operations ?? (IReadOnlyList<OperationPlanNode>)Array.Empty<OperationPlanNode>();

public void AddOperation(OperationPlanNode operation)
{
ArgumentNullException.ThrowIfNull(operation);
(_operations ??= []).Add(operation);
operation.Parent = this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace HotChocolate.Fusion.Planning;

public abstract class PlanNode
{
public PlanNode? Parent { get; internal set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace HotChocolate.Fusion.Planning;

public class RootPlanNode : PlanNode, IOperationPlanNodeProvider
{
private readonly List<OperationPlanNode> _operations = new();

public IReadOnlyList<OperationPlanNode> Operations
=> _operations;

public void AddOperation(OperationPlanNode operation)
{
ArgumentNullException.ThrowIfNull(operation);
_operations.Add(operation);
operation.Parent = this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using HotChocolate.Fusion.Types;
using HotChocolate.Language;

namespace HotChocolate.Fusion.Planning;

/// <summary>
/// The base class for plan nodes that can have child selections.
/// </summary>
public abstract class SelectionPlanNode : PlanNode
{
private List<CompositeDirective>? _directives;
private List<SelectionPlanNode>? _selections;

/// <summary>
/// Initializes a new instance of <see cref="SelectionPlanNode"/>.
/// </summary>
/// <param name="declaringType">
/// The type on which this selection is declared on.
/// </param>
/// <param name="selectionNodes">
/// The child selection syntax nodes of this selection.
/// </param>
protected SelectionPlanNode(
ICompositeNamedType declaringType,
IReadOnlyList<ISelectionNode>? selectionNodes)
{
DeclaringType = declaringType;
IsEntity = declaringType.IsEntity();
SelectionNodes = selectionNodes;
}

/// <summary>
/// Gets the type on which this selection is declared on.
/// </summary>
public ICompositeNamedType DeclaringType { get; }

/// <summary>
/// Defines if the selection is declared on an entity type.
/// </summary>
public bool IsEntity { get; }

/// <summary>
/// Gets the directives that are annotated to this selection.
/// </summary>
public IReadOnlyList<CompositeDirective> Directives
=> _directives ?? (IReadOnlyList<CompositeDirective>)Array.Empty<CompositeDirective>();

/// <summary>
/// Gets the child selection syntax nodes of this selection.
/// </summary>
public IReadOnlyList<ISelectionNode>? SelectionNodes { get; }

/// <summary>
/// Gets the child selections of this selection.
/// </summary>
public IReadOnlyList<SelectionPlanNode> Selections
=> _selections ?? (IReadOnlyList<SelectionPlanNode>)Array.Empty<SelectionPlanNode>();

/// <summary>
/// Adds a child selection to this selection.
/// </summary>
/// <param name="selection">
/// The child selection that shall be added.
/// </param>
public void AddSelection(SelectionPlanNode selection)
{
ArgumentNullException.ThrowIfNull(selection);
(_selections ??= []).Add(selection);
selection.Parent = this;
}

/// <summary>
/// Adds a directive to the selection.
/// </summary>
/// <param name="directive">
/// The directive that shall be added.
/// </param>
public void AddDirective(CompositeDirective directive)
{
ArgumentNullException.ThrowIfNull(directive);
(_directives ??= []).Add(directive);
}
}
Loading

0 comments on commit b521e35

Please sign in to comment.