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

Mark descriptor.Item and descriptor.BindItems as obsolete #3689

Merged
merged 3 commits into from
May 13, 2021
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
@@ -1,4 +1,5 @@
using HotChocolate.Language;
using System;
using HotChocolate.Language;
using HotChocolate.Types.Descriptors.Definitions;

namespace HotChocolate.Types
Expand Down Expand Up @@ -35,12 +36,14 @@ IEnumTypeDescriptor Name(
IEnumTypeDescriptor Description(
string value);

[Obsolete("Use `Value`.")]
IEnumValueDescriptor Item<T>(
T value);

IEnumValueDescriptor Value<T>(
T value);

[Obsolete("Use `BindValues`.")]
IEnumTypeDescriptor BindItems(
BindingBehavior behavior);

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

Expand Down Expand Up @@ -33,10 +34,12 @@ IEnumTypeDescriptor<T> SyntaxNode(
/// </param>
IEnumTypeDescriptor<T> Description(string value);

[Obsolete("Use `Value`.")]
IEnumValueDescriptor Item(T value);

IEnumValueDescriptor Value(T value);

[Obsolete("Use `BindValues`.")]
IEnumTypeDescriptor<T> BindItems(BindingBehavior behavior);

IEnumTypeDescriptor<T> BindValues(BindingBehavior behavior);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public IEnumTypeDescriptor Description(string value)
return this;
}

[Obsolete("Use `BindValues`.")]
public IEnumTypeDescriptor BindItems(
BindingBehavior behavior) =>
BindValues(behavior);
Expand All @@ -120,7 +121,10 @@ public IEnumTypeDescriptor BindValuesExplicitly() =>
public IEnumTypeDescriptor BindValuesImplicitly() =>
BindValues(BindingBehavior.Implicit);

public IEnumValueDescriptor Item<T>(T value)
[Obsolete("Use `Value`.")]
public IEnumValueDescriptor Item<T>(T value) => Value<T>(value);

public IEnumValueDescriptor Value<T>(T value)
{
EnumValueDescriptor descriptor = Values.FirstOrDefault(t =>
t.Definition.Value is not null &&
Expand All @@ -136,8 +140,6 @@ t.Definition.Value is not null &&
return descriptor;
}

public IEnumValueDescriptor Value<T>(T value) => Item<T>(value);

public IEnumTypeDescriptor Directive<T>(T directiveInstance)
where T : class
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using HotChocolate.Language;
using HotChocolate.Types.Descriptors.Definitions;

Expand All @@ -13,7 +14,7 @@ protected internal EnumTypeDescriptor(IDescriptorContext context)
}

protected internal EnumTypeDescriptor(
IDescriptorContext context,
IDescriptorContext context,
EnumTypeDefinition definition)
: base(context, definition)
{
Expand All @@ -38,6 +39,7 @@ protected internal EnumTypeDescriptor(
return this;
}

[Obsolete("Use `BindValues`.")]
public new IEnumTypeDescriptor<T> BindItems(
BindingBehavior behavior) =>
BindValues(behavior);
Expand All @@ -54,13 +56,14 @@ protected internal EnumTypeDescriptor(
public new IEnumTypeDescriptor<T> BindValuesImplicitly() =>
BindValues(BindingBehavior.Implicit);

public IEnumValueDescriptor Item(T value)
[Obsolete("Use `Value`.")]
public IEnumValueDescriptor Item(T value) => Value<T>(value);

public IEnumValueDescriptor Value(T value)
{
return base.Item(value);
return base.Value(value);
}

public IEnumValueDescriptor Value(T value) => Item(value);

public new IEnumTypeDescriptor<T> Directive<TDirective>(
TDirective directiveInstance)
where TDirective : class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,100 +15,100 @@ protected override void Configure(IEnumTypeDescriptor<DirectiveLocation> descrip
.Description(TypeResources.DirectiveLocation_Description)
// Introspection types must always be bound explicitly so that we
// do not get any interference with conventions.
.BindItems(BindingBehavior.Explicit);
.BindValues(BindingBehavior.Explicit);

descriptor
.Item(DirectiveLocation.Query)
.Value(DirectiveLocation.Query)
.Name(Lang.Query.Value)
.Description(TypeResources.DirectiveLocation_Query);

descriptor
.Item(DirectiveLocation.Mutation)
.Value(DirectiveLocation.Mutation)
.Name(Lang.Mutation.Value)
.Description(TypeResources.DirectiveLocation_Mutation);

descriptor
.Item(DirectiveLocation.Subscription)
.Value(DirectiveLocation.Subscription)
.Name(Lang.Subscription.Value)
.Description(TypeResources.DirectiveLocation_Subscription);

descriptor
.Item(DirectiveLocation.Field)
.Value(DirectiveLocation.Field)
.Name(Lang.Field.Value)
.Description(TypeResources.DirectiveLocation_Field);

descriptor
.Item(DirectiveLocation.FragmentDefinition)
.Value(DirectiveLocation.FragmentDefinition)
.Name(Lang.FragmentDefinition.Value)
.Description(TypeResources.DirectiveLocation_FragmentDefinition);

descriptor
.Item(DirectiveLocation.FragmentSpread)
.Value(DirectiveLocation.FragmentSpread)
.Name(Lang.FragmentSpread.Value)
.Description(TypeResources.DirectiveLocation_FragmentSpread);

descriptor
.Item(DirectiveLocation.InlineFragment)
.Value(DirectiveLocation.InlineFragment)
.Name(Lang.InlineFragment.Value)
.Description(TypeResources.DirectiveLocation_InlineFragment);

descriptor
.Item(DirectiveLocation.VariableDefinition)
.Value(DirectiveLocation.VariableDefinition)
.Name(Lang.VariableDefinition.Value)
.Description("Location adjacent to a variable definition.");

descriptor
.Item(DirectiveLocation.Schema)
.Value(DirectiveLocation.Schema)
.Name(Lang.Schema.Value)
.Description(TypeResources.DirectiveLocation_Schema);

descriptor
.Item(DirectiveLocation.Scalar)
.Value(DirectiveLocation.Scalar)
.Name(Lang.Scalar.Value)
.Description(TypeResources.DirectiveLocation_Scalar);

descriptor
.Item(DirectiveLocation.Object)
.Value(DirectiveLocation.Object)
.Name(Lang.Object.Value)
.Description(TypeResources.DirectiveLocation_Object);

descriptor
.Item(DirectiveLocation.FieldDefinition)
.Value(DirectiveLocation.FieldDefinition)
.Name(Lang.FieldDefinition.Value)
.Description(TypeResources.DirectiveLocation_FieldDefinition);

descriptor
.Item(DirectiveLocation.ArgumentDefinition)
.Value(DirectiveLocation.ArgumentDefinition)
.Name(Lang.ArgumentDefinition.Value)
.Description(TypeResources.DirectiveLocation_ArgumentDefinition);

descriptor
.Item(DirectiveLocation.Interface)
.Value(DirectiveLocation.Interface)
.Name(Lang.Interface.Value)
.Description(TypeResources.DirectiveLocation_Interface);

descriptor
.Item(DirectiveLocation.Union)
.Value(DirectiveLocation.Union)
.Name(Lang.Union.Value)
.Description(TypeResources.DirectiveLocation_Union);

descriptor
.Item(DirectiveLocation.Enum)
.Value(DirectiveLocation.Enum)
.Name(Lang.Enum.Value)
.Description(TypeResources.DirectiveLocation_Enum);

descriptor
.Item(DirectiveLocation.EnumValue)
.Value(DirectiveLocation.EnumValue)
.Name(Lang.EnumValue.Value)
.Description(TypeResources.DirectiveLocation_EnumValue);

descriptor
.Item(DirectiveLocation.InputObject)
.Value(DirectiveLocation.InputObject)
.Name(Lang.InputObject.Value)
.Description(TypeResources.DirectiveLocation_InputObject);

descriptor
.Item(DirectiveLocation.InputFieldDefinition)
.Value(DirectiveLocation.InputFieldDefinition)
.Name(Lang.InputFieldDefinition.Value)
.Description(TypeResources.DirectiveLocation_InputFieldDefinition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@ protected override void Configure(IEnumTypeDescriptor<TypeKind> descriptor)
.Description(TypeResources.TypeKind_Description)
// Introspection types must always be bound explicitly so that we
// do not get any interference with conventions.
.BindItems(BindingBehavior.Explicit);
.BindValues(BindingBehavior.Explicit);

descriptor
.Item(TypeKind.Scalar)
.Value(TypeKind.Scalar)
.Name(Names.Scalar)
.Description(TypeResources.TypeKind_Scalar);

descriptor
.Item(TypeKind.Object)
.Value(TypeKind.Object)
.Name(Names.Object)
.Description(TypeResources.TypeKind_Object);

descriptor
.Item(TypeKind.Interface)
.Value(TypeKind.Interface)
.Name(Names.Interface)
.Description(TypeResources.TypeKind_Interface);

descriptor
.Item(TypeKind.Union)
.Value(TypeKind.Union)
.Name(Names.Union)
.Description(TypeResources.TypeKind_Union);

descriptor
.Item(TypeKind.Enum)
.Value(TypeKind.Enum)
.Name(Names.Enum)
.Description(TypeResources.TypeKind_Enum);

descriptor
.Item(TypeKind.InputObject)
.Value(TypeKind.InputObject)
.Name(Names.InputObject)
.Description(TypeResources.TypeKind_InputObject);

descriptor
.Item(TypeKind.List)
.Value(TypeKind.List)
.Name(Names.List)
.Description(TypeResources.TypeKind_List);

descriptor
.Item(TypeKind.NonNull)
.Value(TypeKind.NonNull)
.Name(Names.NonNull)
.Description(TypeResources.TypeKind_NonNull);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void SpecifyOneValueInferTheOthers()

// act
IEnumTypeDescriptor desc = descriptor;
desc.Item(FooEnum.Bar1).Name("FOOBAR");
desc.Value(FooEnum.Bar1).Name("FOOBAR");

// assert
EnumTypeDefinition description = descriptor.CreateDefinition();
Expand All @@ -83,7 +83,7 @@ public void ExplicitValueBinding()

// act
IEnumTypeDescriptor desc = descriptor;
desc.Item(FooEnum.Bar1).Name("FOOBAR");
desc.Value(FooEnum.Bar1).Name("FOOBAR");
desc.BindValues(BindingBehavior.Explicit);

// assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void EnumTypeExtension_AddValueThatDoesNotMatchClrType()
.AddType<FooType>()
.AddType(new EnumTypeExtension(d => d
.Name("Foo")
.Item("FOOBAR")))
.Value("FOOBAR")))
.Create();

// assert
Expand Down Expand Up @@ -134,8 +134,8 @@ protected override void Configure(
IEnumTypeDescriptor<Foo> descriptor)
{
descriptor.BindValues(BindingBehavior.Explicit);
descriptor.Item(Foo.Bar);
descriptor.Item(Foo.Baz);
descriptor.Value(Foo.Bar);
descriptor.Value(Foo.Baz);
}
}

Expand All @@ -145,7 +145,7 @@ public class FooTypeExtension
protected override void Configure(IEnumTypeDescriptor descriptor)
{
descriptor.Name("Foo");
descriptor.Item(Foo.Quox).Name("_QUOX");
descriptor.Value(Foo.Quox).Name("_QUOX");
}
}

Expand Down
Loading