Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Data Definitions readonly #2447

Merged
merged 2 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public NameString GetOperationName(int operation)

public bool TryGetHandler(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition,
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition,
[NotNullWhen(true)] out IFilterFieldHandler? handler)
{
foreach (IFilterFieldHandler filterFieldHandler in _provider.FieldHandlers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public interface IFilterConvention : IConvention

bool TryGetHandler(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition,
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition,
[NotNullWhen(true)] out IFilterFieldHandler? handler);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public abstract class QueryableBooleanOperationHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is BooleanOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public abstract class QueryableComparableOperationHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IComparableOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class QueryableEnumEqualsHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IEnumOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class QueryableEnumInHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IEnumOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class QueryableEnumNotEqualsHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IEnumOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class QueryableEnumNotInHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IEnumOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class QueryableListAnyOperationHandler

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IListFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public abstract class QueryableListOperationHandlerBase

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is IListFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class QueryableDataOperationHandler
{
public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return fieldDefinition is FilterOperationFieldDefinition def &&
def.Id == DefaultOperations.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class QueryableDefaultFieldHandler
{
public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition) =>
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition) =>
!(fieldDefinition is FilterOperationFieldDefinition) &&
fieldDefinition.Member is not null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public abstract class QueryableStringOperationHandler : QueryableOperationHandle

public override bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition)
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition)
{
return context.Type is StringOperationFilterInput &&
fieldDefinition is FilterOperationFieldDefinition operationField &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace HotChocolate.Data.Filters
public class FilterFieldDefinition
: InputFieldDefinition
, IHasScope
, IFilterFieldDefinition
{
public MemberInfo? Member { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace HotChocolate.Data.Filters
public class FilterInputTypeDefinition
: InputObjectTypeDefinition
, IHasScope
, IFilterInputTypeDefinition
{
public Type? EntityType { get; set; }

Expand Down
13 changes: 13 additions & 0 deletions src/HotChocolate/Data/src/Data/Filters/IFilterFieldDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Reflection;

namespace HotChocolate.Data.Filters
{
public interface IFilterFieldDefinition
{
MemberInfo? Member { get; set; }

IFilterFieldHandler? Handler { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not read-only

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the PR and only looked for formatting issues


string? Scope { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace HotChocolate.Data.Filters
{
public interface IFilterInputTypeDefinition
{
Type? EntityType { get; }

string? Scope { get; }

bool UseOr { get; }

bool UseAnd { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class FilterFieldHandler<TContext, T>
/// <inheritdoc />
public abstract bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition);
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface IFilterFieldHandler
{
bool CanHandle(
ITypeDiscoveryContext context,
FilterInputTypeDefinition typeDefinition,
FilterFieldDefinition fieldDefinition);
IFilterInputTypeDefinition typeDefinition,
IFilterFieldDefinition fieldDefinition);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public interface ISortConvention : IConvention

bool TryGetFieldHandler(
ITypeDiscoveryContext context,
SortInputTypeDefinition typeDefinition,
SortFieldDefinition fieldDefinition,
ISortInputTypeDefinition typeDefinition,
ISortFieldDefinition fieldDefinition,
[NotNullWhen(true)] out ISortFieldHandler? handler);

bool TryGetOperationHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ public NameString GetOperationName(int operation)

public bool TryGetFieldHandler(
ITypeDiscoveryContext context,
SortInputTypeDefinition typeDefinition,
SortFieldDefinition fieldDefinition,
ISortInputTypeDefinition typeDefinition,
ISortFieldDefinition fieldDefinition,
[NotNullWhen(true)] out ISortFieldHandler? handler)
{
foreach (ISortFieldHandler sortFieldHandler in _provider.FieldHandlers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class QueryableDefaultFieldHandler
{
public override bool CanHandle(
ITypeDiscoveryContext context,
SortInputTypeDefinition typeDefinition,
SortFieldDefinition fieldDefinition) =>
ISortInputTypeDefinition typeDefinition,
ISortFieldDefinition fieldDefinition) =>
fieldDefinition.Member is not null;

public override bool TryHandleEnter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ public static class SortObjectFieldDescriptorExtensions
LazyTypeConfigurationBuilder
.New<ObjectFieldDefinition>()
.Definition(definition)
.Configure((context, defintion) =>
.Configure((context, def) =>
CompileMiddleware(
context,
definition,
def,
argumentTypeReference,
placeholder,
scope))
Expand All @@ -193,7 +193,7 @@ public static class SortObjectFieldDescriptorExtensions
LazyTypeConfigurationBuilder
.New<ObjectFieldDefinition>()
.Definition(definition)
.Configure((context, defintion) =>
.Configure((context, _) =>
argumentDefinition.Name =
context.GetSortConvention(scope).GetArgumentName())
.On(ApplyConfigurationOn.Naming)
Expand Down
13 changes: 13 additions & 0 deletions src/HotChocolate/Data/src/Data/Sorting/ISortFieldDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Reflection;
using HotChocolate.Types;

namespace HotChocolate.Data.Sorting
{
public interface ISortFieldDefinition
: IHasScope
{
public MemberInfo? Member { get; }

public ISortFieldHandler? Handler { get; }
}
}
12 changes: 12 additions & 0 deletions src/HotChocolate/Data/src/Data/Sorting/ISortInputTypeDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors.Definitions;

namespace HotChocolate.Data.Sorting
{
public interface ISortInputTypeDefinition
: IHasScope
{
Type? EntityType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Reflection;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors.Definitions;

namespace HotChocolate.Data.Sorting
{
public class SortFieldDefinition
: InputFieldDefinition
, IHasScope
, ISortFieldDefinition
{
public MemberInfo? Member { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors.Definitions;

namespace HotChocolate.Data.Sorting
{
public class SortInputTypeDefinition
: InputObjectTypeDefinition
, IHasScope
, ISortInputTypeDefinition
{
public Type? EntityType { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface ISortFieldHandler
{
bool CanHandle(
ITypeDiscoveryContext context,
SortInputTypeDefinition typeDefinition,
SortFieldDefinition fieldDefinition);
ISortInputTypeDefinition typeDefinition,
ISortFieldDefinition fieldDefinition);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class SortFieldHandler<TContext, T>
/// <inheritdoc />
public abstract bool CanHandle(
ITypeDiscoveryContext context,
SortInputTypeDefinition typeDefinition,
SortFieldDefinition fieldDefinition);
ISortInputTypeDefinition typeDefinition,
ISortFieldDefinition fieldDefinition);
}
}