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

Refined unignore for V10 #1468

Merged
merged 4 commits into from
Mar 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ IDirectiveArgumentDescriptor Type<TInputType>(TInputType inputType)

IDirectiveArgumentDescriptor DefaultValue(object value);

IDirectiveArgumentDescriptor Ignore();
IDirectiveArgumentDescriptor Ignore(bool ignore = true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ IInputFieldDescriptor Type<TInputType>(TInputType inputType)

IInputFieldDescriptor Type(Type type);

IInputFieldDescriptor Ignore();
IInputFieldDescriptor Ignore(bool ignore = true);

IInputFieldDescriptor DefaultValue(IValueNode value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,4 @@ IObjectTypeDescriptor<T> Directive(
NameString name,
params ArgumentNode[] arguments);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public IDirectiveArgumentDescriptor Name(
return this;
}

public IDirectiveArgumentDescriptor Ignore()
public IDirectiveArgumentDescriptor Ignore(bool ignore)
{
Definition.Ignore = true;
Definition.Ignore = ignore;
return this;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Core/Types/Types/Descriptors/DirectiveTypeDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ public IDirectiveTypeDescriptor Description(string value)
public IDirectiveArgumentDescriptor Argument(NameString name)
{
DirectiveArgumentDescriptor descriptor =
Arguments.FirstOrDefault(t => t.Definition.Name.Equals(name));
Arguments.FirstOrDefault(t =>
t.Definition.Name.Equals(name)
&& !t.Definition.Ignore);

if (descriptor is { })
{
return descriptor;
Expand Down
2 changes: 0 additions & 2 deletions src/Core/Types/Types/Descriptors/DirectiveTypeDescriptor~1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ protected override void OnCompleteArguments(
base.OnCompleteArguments(arguments, handledProperties);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is also using ``Arguments`

 public IDirectiveArgumentDescriptor Argument(
            Expression<Func<T, object>> property)
        {




#region IDirectiveDescriptor<T>

public new IDirectiveTypeDescriptor<T> SyntaxNode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.Linq.Expressions;
using HotChocolate.Resolvers;

namespace HotChocolate.Types
{
public static class DirectiveTypeDescriptorExtensions
{
public static IDirectiveTypeDescriptor<T> Ignore<T>(
this IDirectiveTypeDescriptor<T> descriptor,
Expression<Func<T, object>> property)
Expression<Func<T, object>> property,
bool ignore = true)
{
if (descriptor == null)
{
Expand All @@ -20,7 +20,7 @@ public static IDirectiveTypeDescriptor<T> Ignore<T>(
throw new ArgumentNullException(nameof(property));
}

descriptor.Argument(property).Ignore();
descriptor.Argument(property).Ignore(ignore);
return descriptor;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public static class InputObjectTypeDescriptorExtensions
{
public static IInputObjectTypeDescriptor<T> Ignore<T>(
this IInputObjectTypeDescriptor<T> descriptor,
Expression<Func<T, object>> property)
Expression<Func<T, object>> property,
bool ignore = true)
{
if (descriptor == null)
{
Expand All @@ -19,7 +20,7 @@ public static IInputObjectTypeDescriptor<T> Ignore<T>(
throw new ArgumentNullException(nameof(property));
}

descriptor.Field(property).Ignore();
descriptor.Field(property).Ignore(ignore);
return descriptor;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public static class InterfaceTypeDescriptorExtensions
{
public static IInterfaceTypeDescriptor<T> Ignore<T>(
this IInterfaceTypeDescriptor<T> descriptor,
Expression<Func<T, object>> propertyOrMethod)
Expression<Func<T, object>> propertyOrMethod,
bool ignore = true)
{
if (descriptor == null)
{
Expand All @@ -19,7 +20,7 @@ public static IInterfaceTypeDescriptor<T> Ignore<T>(
throw new ArgumentNullException(nameof(propertyOrMethod));
}

descriptor.Field(propertyOrMethod).Ignore();
descriptor.Field(propertyOrMethod).Ignore(ignore);
return descriptor;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public static class ObjectTypeDescriptorExtensions
{
public static IObjectTypeDescriptor<T> Ignore<T>(
this IObjectTypeDescriptor<T> descriptor,
Expression<Func<T, object>> propertyOrMethod)
Expression<Func<T, object>> propertyOrMethod,
bool ignore = true)
{
if (descriptor == null)
{
Expand All @@ -19,7 +20,7 @@ public static IObjectTypeDescriptor<T> Ignore<T>(
throw new ArgumentNullException(nameof(propertyOrMethod));
}

descriptor.Field(propertyOrMethod).Ignore();
descriptor.Field(propertyOrMethod).Ignore(ignore);
return descriptor;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Types/Types/Descriptors/InputFieldDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public IInputFieldDescriptor Name(NameString value)
return this;
}

public IInputFieldDescriptor Ignore()
public IInputFieldDescriptor Ignore(bool ignore = true)
{
Definition.Ignore = true;
Definition.Ignore = ignore;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public IInputObjectTypeDescriptor Description(string value)
public IInputFieldDescriptor Field(NameString name)
{
InputFieldDescriptor fieldDescriptor =
Fields.FirstOrDefault(t => t.Definition.Name.Equals(name));
Fields.FirstOrDefault(t =>
t.Definition.Name.Equals(name)
&& !t.Definition.Ignore);

if (fieldDescriptor is { })
{
return fieldDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public IInputFieldDescriptor Field<TValue>(
{
InputFieldDescriptor fieldDescriptor =
Fields.FirstOrDefault(t => t.Definition.Property == p);

if (fieldDescriptor is { })
{
return fieldDescriptor;
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Types/Types/Descriptors/InterfaceTypeDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ public IInterfaceTypeDescriptor Description(string value)
public IInterfaceFieldDescriptor Field(NameString name)
{
InterfaceFieldDescriptor fieldDescriptor =
Fields.FirstOrDefault(t => t.Definition.Name.Equals(name));
Fields.FirstOrDefault(t =>
t.Definition.Name.Equals(name)
&& !t.Definition.Ignore);
Copy link
Member

Choose a reason for hiding this comment

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

Fields is also used in the generic version because of Field(x => x.Property)


if (fieldDescriptor is { })
{
return fieldDescriptor;
Expand Down
4 changes: 3 additions & 1 deletion src/Core/Types/Types/Descriptors/ObjectTypeDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ public IObjectTypeDescriptor IsOfType(IsOfType isOfType)
public IObjectFieldDescriptor Field(NameString name)
{
ObjectFieldDescriptor fieldDescriptor =
Fields.FirstOrDefault(t => t.Definition.Name.Equals(name));
Fields.FirstOrDefault(t =>
t.Definition.Name.Equals(name)
&& !t.Definition.Ignore);
Copy link
Member

Choose a reason for hiding this comment

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

Fields is also used in the generic version because of Field(x => x.Property)

Copy link
Member Author

Choose a reason for hiding this comment

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

But in that case it does not matter since the collision is only on names. I however think we should change the data structure to better controls ignored members.

if (fieldDescriptor is { })
{
return fieldDescriptor;
Expand Down