-
-
Notifications
You must be signed in to change notification settings - Fork 725
/
ISortConvention.cs
154 lines (141 loc) · 5.39 KB
/
ISortConvention.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using HotChocolate.Configuration;
using HotChocolate.Resolvers;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;
namespace HotChocolate.Data.Sorting
{
/// <summary>
/// The sort convention provides defaults for inferring sorting fields.
/// </summary>
public interface ISortConvention : IConvention
{
/// <summary>
/// Gets the GraphQL type name from a runtime type.
/// </summary>
/// <param name="runtimeType">
/// The runtime type.
/// </param>
/// <returns>
/// Returns the GraphQL type name that was inferred from the <paramref name="runtimeType"/>.
/// </returns>
NameString GetTypeName(Type runtimeType);
/// <summary>
/// Gets the GraphQL type description from a runtime type.
/// </summary>
/// <param name="runtimeType">
/// The runtime type.
/// </param>
/// <returns>
/// Returns the GraphQL type description that was
/// inferred from the <paramref name="runtimeType"/>.
/// </returns>
string? GetTypeDescription(Type runtimeType);
/// <summary>
/// Gets the GraphQL field name from a <see cref="MemberInfo"/>.
/// </summary>
/// <param name="member">
/// The member from which a field shall be inferred.
/// </param>
/// <returns>
/// Returns the GraphQL field name that was inferred from the <see cref="MemberInfo"/>.
/// </returns>
NameString GetFieldName(MemberInfo member);
/// <summary>
/// Gets the GraphQL field description from a <see cref="MemberInfo"/>.
/// </summary>
/// <param name="member">
/// The member from which a field shall be inferred.
/// </param>
/// <returns>
/// Returns the GraphQL field description that was inferred from the
/// <see cref="MemberInfo"/>.
/// </returns>
string? GetFieldDescription(MemberInfo member);
/// <summary>
/// Extracts the field type from a <see cref="MemberInfo"/>.
/// </summary>
/// <param name="member">
/// The member from which a field shall be inferred.
/// </param>
/// <returns>
/// Returns a <see cref="ClrTypeReference"/> that represents the field type.
/// </returns>
ExtendedTypeReference GetFieldType(MemberInfo member);
/// <summary>
/// Gets the operation name for the provided <paramref name="operationId"/>.
/// </summary>
/// <param name="operationId">
/// The internal operation ID.
/// </param>
/// <returns>
/// Returns the operation name.
/// </returns>
NameString GetOperationName(int operationId);
/// <summary>
/// Gets the operation description for the provided <paramref name="operationId"/>.
/// </summary>
/// <param name="operationId">
/// The internal operation ID.
/// </param>
/// <returns>
/// Returns the operation description.
/// </returns>
string? GetOperationDescription(int operationId);
/// <summary>
/// Gets the sort argument name.
/// </summary>
/// <returns>
/// Returns the sort argument name.
/// </returns>
NameString GetArgumentName();
/// <summary>
/// Applies configurations to a sort type.
/// </summary>
/// <param name="typeReference">
/// The type reference representing the type.
/// </param>
/// <param name="descriptor">
/// The descriptor to which the configurations shall be applied to.
/// </param>
void ApplyConfigurations(
ITypeReference typeReference,
ISortInputTypeDescriptor descriptor);
/// <summary>
/// Applies configurations to a sort enum type.
/// </summary>
/// <param name="typeReference">
/// The type reference representing the enum type.
/// </param>
/// <param name="descriptor">
/// The descriptor to which the configurations shall be applied to.
/// </param>
void ApplyConfigurations(
ITypeReference typeReference,
ISortEnumTypeDescriptor descriptor);
bool TryGetFieldHandler(
ITypeDiscoveryContext context,
ISortInputTypeDefinition typeDefinition,
ISortFieldDefinition fieldDefinition,
[NotNullWhen(true)] out ISortFieldHandler? handler);
bool TryGetOperationHandler(
ITypeDiscoveryContext context,
EnumTypeDefinition typeDefinition,
SortEnumValueDefinition fieldDefinition,
[NotNullWhen(true)] out ISortOperationHandler? handler);
/// <summary>
/// Creates a middleware that represents the sort execution logic
/// for the specified entity type.
/// </summary>
/// <typeparam name="TEntityType">
/// The entity type for which an sort executor shall be created.
/// </typeparam>
/// <returns>
/// Returns a field middleware which represents the sort execution logic
/// for the specified entity type.
/// </returns>
FieldMiddleware CreateExecutor<TEntityType>();
}
}