-
-
Notifications
You must be signed in to change notification settings - Fork 723
/
FilterFieldDefinition.cs
74 lines (60 loc) · 1.88 KB
/
FilterFieldDefinition.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
using System.Linq.Expressions;
using System;
using System.Collections.Generic;
using System.Reflection;
using HotChocolate.Internal;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;
namespace HotChocolate.Data.Filters;
public class FilterFieldDefinition
: InputFieldDefinition
, IFilterFieldDefinition
{
private List<int>? _allowedOperations;
public MemberInfo? Member { get; set; }
public IFilterFieldHandler? Handler { get; set; }
public Expression? Expression { get; set; }
internal IFilterMetadata? Metadata { get; set; }
public string? Scope { get; set; }
public List<int> AllowedOperations => _allowedOperations ??= new List<int>();
public bool HasAllowedOperations => _allowedOperations?.Count > 0;
public Func<IDescriptorContext, string?, FilterInputTypeDefinition>? CreateFieldTypeDefinition
{
get;
set;
}
internal void CopyTo(FilterFieldDefinition target)
{
base.CopyTo(target);
target.Member = Member;
target._allowedOperations = _allowedOperations;
target.Handler = Handler;
target.Scope = Scope;
target.CreateFieldTypeDefinition = CreateFieldTypeDefinition;
}
internal void MergeInto(FilterFieldDefinition target)
{
base.MergeInto(target);
if (Member is not null)
{
target.Member = Member;
}
if (_allowedOperations is { Count: > 0 })
{
target._allowedOperations = _allowedOperations;
}
if (Handler is not null)
{
target.Handler = Handler;
}
if (Scope is not null)
{
target.Scope = Scope;
}
if (CreateFieldTypeDefinition is not null)
{
target.CreateFieldTypeDefinition = CreateFieldTypeDefinition;
}
}
}