Skip to content

Commit

Permalink
Refined Fragment Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Nov 8, 2022
1 parent e5627fc commit aa2fa7c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/HotChocolate/Core/src/Execution/Processing/Fragment.cs
Expand Up @@ -14,7 +14,6 @@ internal sealed class Fragment : IFragment
IObjectType typeCondition,
ISyntaxNode syntaxNode,
IReadOnlyList<DirectiveNode> directives,
int selectionSetId,
ISelectionSet selectionSet,
long includeCondition,
long deferIfCondition,
Expand All @@ -24,7 +23,6 @@ internal sealed class Fragment : IFragment
TypeCondition = typeCondition;
SyntaxNode = syntaxNode;
Directives = directives;
SelectionSetId = selectionSetId;
SelectionSet = selectionSet;
_includeCondition = includeCondition;
_deferIfCondition = deferIfCondition;
Expand All @@ -39,8 +37,6 @@ internal sealed class Fragment : IFragment

public IReadOnlyList<DirectiveNode> Directives { get; }

public int SelectionSetId { get; }

public ISelectionSet SelectionSet { get; }

public bool IsInternal { get; }
Expand Down
Expand Up @@ -76,7 +76,7 @@ private static SelectionSetNode Visit(PrintContext context)

foreach (var fragment in selectionSet.Fragments)
{
if (context.GetOrCreateFragmentName(fragment.SelectionSetId, out var fragmentName))
if (context.GetOrCreateFragmentName(fragment.SelectionSet.Id, out var fragmentName))
{
var index = context.Definitions.Count;
context.Definitions.Add(default!);
Expand Down
29 changes: 27 additions & 2 deletions src/HotChocolate/Core/src/Types/Execution/Processing/IFragment.cs
Expand Up @@ -6,19 +6,44 @@

namespace HotChocolate.Execution.Processing;

/// <summary>
/// Represents a deferred fragment.
/// </summary>
public interface IFragment : IOptionalSelection
{
/// <summary>
/// Gets the internal fragment identifier.
/// </summary>
public int Id { get; }

/// <summary>
/// Gets the type condition.
/// </summary>
IObjectType TypeCondition { get; }

/// <summary>
/// Gets the syntax node from the original GraphQL request document.
/// </summary>
ISyntaxNode SyntaxNode { get; }

/// <summary>
/// Gets the collection of directives that are annotated to this fragment.
/// </summary>
IReadOnlyList<DirectiveNode> Directives { get; }

int SelectionSetId { get; }

/// <summary>
/// Gets the selection set of this fragment.
/// </summary>
ISelectionSet SelectionSet { get; }

/// <summary>
/// Gets the fragment label.
/// </summary>
/// <param name="variables">
/// The variable values.
/// </param>
/// <returns>
/// Returns the fragment label.
/// </returns>
string? GetLabel(IVariableValueCollection variables);
}

0 comments on commit aa2fa7c

Please sign in to comment.