From aa2fa7c19e6c04f8e388b190c98181c21cd58718 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 8 Nov 2022 09:13:59 +0100 Subject: [PATCH] Refined Fragment Interface --- .../Core/src/Execution/Processing/Fragment.cs | 4 --- .../Execution/Processing/OperationPrinter.cs | 2 +- .../Types/Execution/Processing/IFragment.cs | 29 +++++++++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/HotChocolate/Core/src/Execution/Processing/Fragment.cs b/src/HotChocolate/Core/src/Execution/Processing/Fragment.cs index 568b0ebe554..bffeae40726 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/Fragment.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/Fragment.cs @@ -14,7 +14,6 @@ internal sealed class Fragment : IFragment IObjectType typeCondition, ISyntaxNode syntaxNode, IReadOnlyList directives, - int selectionSetId, ISelectionSet selectionSet, long includeCondition, long deferIfCondition, @@ -24,7 +23,6 @@ internal sealed class Fragment : IFragment TypeCondition = typeCondition; SyntaxNode = syntaxNode; Directives = directives; - SelectionSetId = selectionSetId; SelectionSet = selectionSet; _includeCondition = includeCondition; _deferIfCondition = deferIfCondition; @@ -39,8 +37,6 @@ internal sealed class Fragment : IFragment public IReadOnlyList Directives { get; } - public int SelectionSetId { get; } - public ISelectionSet SelectionSet { get; } public bool IsInternal { get; } diff --git a/src/HotChocolate/Core/src/Execution/Processing/OperationPrinter.cs b/src/HotChocolate/Core/src/Execution/Processing/OperationPrinter.cs index c1d1f928dbc..44a5990223d 100644 --- a/src/HotChocolate/Core/src/Execution/Processing/OperationPrinter.cs +++ b/src/HotChocolate/Core/src/Execution/Processing/OperationPrinter.cs @@ -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!); diff --git a/src/HotChocolate/Core/src/Types/Execution/Processing/IFragment.cs b/src/HotChocolate/Core/src/Types/Execution/Processing/IFragment.cs index 688e9c233f5..f3930d0b523 100644 --- a/src/HotChocolate/Core/src/Types/Execution/Processing/IFragment.cs +++ b/src/HotChocolate/Core/src/Types/Execution/Processing/IFragment.cs @@ -6,19 +6,44 @@ namespace HotChocolate.Execution.Processing; +/// +/// Represents a deferred fragment. +/// public interface IFragment : IOptionalSelection { + /// + /// Gets the internal fragment identifier. + /// public int Id { get; } + /// + /// Gets the type condition. + /// IObjectType TypeCondition { get; } + /// + /// Gets the syntax node from the original GraphQL request document. + /// ISyntaxNode SyntaxNode { get; } + /// + /// Gets the collection of directives that are annotated to this fragment. + /// IReadOnlyList Directives { get; } - int SelectionSetId { get; } - + /// + /// Gets the selection set of this fragment. + /// ISelectionSet SelectionSet { get; } + /// + /// Gets the fragment label. + /// + /// + /// The variable values. + /// + /// + /// Returns the fragment label. + /// string? GetLabel(IVariableValueCollection variables); }