-
-
Notifications
You must be signed in to change notification settings - Fork 725
/
QueryTypeAttribute.cs
43 lines (35 loc) · 1.16 KB
/
QueryTypeAttribute.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
using System;
using HotChocolate.Internal;
using HotChocolate.Types.Descriptors;
namespace HotChocolate.Types;
/// <summary>
/// Marks a class as an extension of the query operation type.
/// </summary>
public sealed class QueryTypeAttribute
: ObjectTypeDescriptorAttribute
, ITypeAttribute
{
/// <summary>
/// Defines if this attribute is inherited. The default is <c>false</c>.
/// </summary>
public bool Inherited { get; set; }
/// <summary>
/// Defines that static members are included.
/// </summary>
public bool IncludeStaticMembers { get; set; }
TypeKind ITypeAttribute.Kind => TypeKind.Object;
bool ITypeAttribute.IsTypeExtension => true;
protected override void OnConfigure(
IDescriptorContext context,
IObjectTypeDescriptor descriptor,
Type type)
{
descriptor.Name(OperationTypeNames.Query);
var definition = descriptor.Extend().Definition;
definition.Fields.BindingBehavior = BindingBehavior.Implicit;
if (IncludeStaticMembers)
{
definition.FieldBindingFlags = FieldBindingFlags.Instance | FieldBindingFlags.Static;
}
}
}