Skip to content

Commit 7bcbb08

Browse files
authoredMay 13, 2021
Mark descriptor.Item and descriptor.BindItems as obsolete (#3689)
1 parent c7e90ef commit 7bcbb08

File tree

9 files changed

+66
-55
lines changed

9 files changed

+66
-55
lines changed
 

‎src/HotChocolate/Core/src/Types/Types/Descriptors/Contracts/IEnumTypeDescriptor.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using HotChocolate.Language;
1+
using System;
2+
using HotChocolate.Language;
23
using HotChocolate.Types.Descriptors.Definitions;
34

45
namespace HotChocolate.Types
@@ -35,12 +36,14 @@ IEnumTypeDescriptor Name(
3536
IEnumTypeDescriptor Description(
3637
string value);
3738

39+
[Obsolete("Use `Value`.")]
3840
IEnumValueDescriptor Item<T>(
3941
T value);
4042

4143
IEnumValueDescriptor Value<T>(
4244
T value);
4345

46+
[Obsolete("Use `BindValues`.")]
4447
IEnumTypeDescriptor BindItems(
4548
BindingBehavior behavior);
4649

‎src/HotChocolate/Core/src/Types/Types/Descriptors/Contracts/IEnumTypeDescriptor~1.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using HotChocolate.Language;
23
using HotChocolate.Types.Descriptors.Definitions;
34

@@ -33,10 +34,12 @@ IEnumTypeDescriptor<T> SyntaxNode(
3334
/// </param>
3435
IEnumTypeDescriptor<T> Description(string value);
3536

37+
[Obsolete("Use `Value`.")]
3638
IEnumValueDescriptor Item(T value);
3739

3840
IEnumValueDescriptor Value(T value);
3941

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

4245
IEnumTypeDescriptor<T> BindValues(BindingBehavior behavior);

‎src/HotChocolate/Core/src/Types/Types/Descriptors/EnumTypeDescriptor.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public IEnumTypeDescriptor Description(string value)
103103
return this;
104104
}
105105

106+
[Obsolete("Use `BindValues`.")]
106107
public IEnumTypeDescriptor BindItems(
107108
BindingBehavior behavior) =>
108109
BindValues(behavior);
@@ -120,7 +121,10 @@ public IEnumTypeDescriptor BindValuesExplicitly() =>
120121
public IEnumTypeDescriptor BindValuesImplicitly() =>
121122
BindValues(BindingBehavior.Implicit);
122123

123-
public IEnumValueDescriptor Item<T>(T value)
124+
[Obsolete("Use `Value`.")]
125+
public IEnumValueDescriptor Item<T>(T value) => Value<T>(value);
126+
127+
public IEnumValueDescriptor Value<T>(T value)
124128
{
125129
EnumValueDescriptor descriptor = Values.FirstOrDefault(t =>
126130
t.Definition.Value is not null &&
@@ -136,8 +140,6 @@ t.Definition.Value is not null &&
136140
return descriptor;
137141
}
138142

139-
public IEnumValueDescriptor Value<T>(T value) => Item<T>(value);
140-
141143
public IEnumTypeDescriptor Directive<T>(T directiveInstance)
142144
where T : class
143145
{

‎src/HotChocolate/Core/src/Types/Types/Descriptors/EnumTypeDescriptor~1.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using HotChocolate.Language;
23
using HotChocolate.Types.Descriptors.Definitions;
34

@@ -13,7 +14,7 @@ protected internal EnumTypeDescriptor(IDescriptorContext context)
1314
}
1415

1516
protected internal EnumTypeDescriptor(
16-
IDescriptorContext context,
17+
IDescriptorContext context,
1718
EnumTypeDefinition definition)
1819
: base(context, definition)
1920
{
@@ -38,6 +39,7 @@ protected internal EnumTypeDescriptor(
3839
return this;
3940
}
4041

42+
[Obsolete("Use `BindValues`.")]
4143
public new IEnumTypeDescriptor<T> BindItems(
4244
BindingBehavior behavior) =>
4345
BindValues(behavior);
@@ -54,13 +56,14 @@ protected internal EnumTypeDescriptor(
5456
public new IEnumTypeDescriptor<T> BindValuesImplicitly() =>
5557
BindValues(BindingBehavior.Implicit);
5658

57-
public IEnumValueDescriptor Item(T value)
59+
[Obsolete("Use `Value`.")]
60+
public IEnumValueDescriptor Item(T value) => Value<T>(value);
61+
62+
public IEnumValueDescriptor Value(T value)
5863
{
59-
return base.Item(value);
64+
return base.Value(value);
6065
}
6166

62-
public IEnumValueDescriptor Value(T value) => Item(value);
63-
6467
public new IEnumTypeDescriptor<T> Directive<TDirective>(
6568
TDirective directiveInstance)
6669
where TDirective : class

‎src/HotChocolate/Core/src/Types/Types/Introspection/__DirectiveLocation.cs

+20-20
Original file line numberDiff line numberDiff line change
@@ -15,100 +15,100 @@ protected override void Configure(IEnumTypeDescriptor<DirectiveLocation> descrip
1515
.Description(TypeResources.DirectiveLocation_Description)
1616
// Introspection types must always be bound explicitly so that we
1717
// do not get any interference with conventions.
18-
.BindItems(BindingBehavior.Explicit);
18+
.BindValues(BindingBehavior.Explicit);
1919

2020
descriptor
21-
.Item(DirectiveLocation.Query)
21+
.Value(DirectiveLocation.Query)
2222
.Name(Lang.Query.Value)
2323
.Description(TypeResources.DirectiveLocation_Query);
2424

2525
descriptor
26-
.Item(DirectiveLocation.Mutation)
26+
.Value(DirectiveLocation.Mutation)
2727
.Name(Lang.Mutation.Value)
2828
.Description(TypeResources.DirectiveLocation_Mutation);
2929

3030
descriptor
31-
.Item(DirectiveLocation.Subscription)
31+
.Value(DirectiveLocation.Subscription)
3232
.Name(Lang.Subscription.Value)
3333
.Description(TypeResources.DirectiveLocation_Subscription);
3434

3535
descriptor
36-
.Item(DirectiveLocation.Field)
36+
.Value(DirectiveLocation.Field)
3737
.Name(Lang.Field.Value)
3838
.Description(TypeResources.DirectiveLocation_Field);
3939

4040
descriptor
41-
.Item(DirectiveLocation.FragmentDefinition)
41+
.Value(DirectiveLocation.FragmentDefinition)
4242
.Name(Lang.FragmentDefinition.Value)
4343
.Description(TypeResources.DirectiveLocation_FragmentDefinition);
4444

4545
descriptor
46-
.Item(DirectiveLocation.FragmentSpread)
46+
.Value(DirectiveLocation.FragmentSpread)
4747
.Name(Lang.FragmentSpread.Value)
4848
.Description(TypeResources.DirectiveLocation_FragmentSpread);
4949

5050
descriptor
51-
.Item(DirectiveLocation.InlineFragment)
51+
.Value(DirectiveLocation.InlineFragment)
5252
.Name(Lang.InlineFragment.Value)
5353
.Description(TypeResources.DirectiveLocation_InlineFragment);
5454

5555
descriptor
56-
.Item(DirectiveLocation.VariableDefinition)
56+
.Value(DirectiveLocation.VariableDefinition)
5757
.Name(Lang.VariableDefinition.Value)
5858
.Description("Location adjacent to a variable definition.");
5959

6060
descriptor
61-
.Item(DirectiveLocation.Schema)
61+
.Value(DirectiveLocation.Schema)
6262
.Name(Lang.Schema.Value)
6363
.Description(TypeResources.DirectiveLocation_Schema);
6464

6565
descriptor
66-
.Item(DirectiveLocation.Scalar)
66+
.Value(DirectiveLocation.Scalar)
6767
.Name(Lang.Scalar.Value)
6868
.Description(TypeResources.DirectiveLocation_Scalar);
6969

7070
descriptor
71-
.Item(DirectiveLocation.Object)
71+
.Value(DirectiveLocation.Object)
7272
.Name(Lang.Object.Value)
7373
.Description(TypeResources.DirectiveLocation_Object);
7474

7575
descriptor
76-
.Item(DirectiveLocation.FieldDefinition)
76+
.Value(DirectiveLocation.FieldDefinition)
7777
.Name(Lang.FieldDefinition.Value)
7878
.Description(TypeResources.DirectiveLocation_FieldDefinition);
7979

8080
descriptor
81-
.Item(DirectiveLocation.ArgumentDefinition)
81+
.Value(DirectiveLocation.ArgumentDefinition)
8282
.Name(Lang.ArgumentDefinition.Value)
8383
.Description(TypeResources.DirectiveLocation_ArgumentDefinition);
8484

8585
descriptor
86-
.Item(DirectiveLocation.Interface)
86+
.Value(DirectiveLocation.Interface)
8787
.Name(Lang.Interface.Value)
8888
.Description(TypeResources.DirectiveLocation_Interface);
8989

9090
descriptor
91-
.Item(DirectiveLocation.Union)
91+
.Value(DirectiveLocation.Union)
9292
.Name(Lang.Union.Value)
9393
.Description(TypeResources.DirectiveLocation_Union);
9494

9595
descriptor
96-
.Item(DirectiveLocation.Enum)
96+
.Value(DirectiveLocation.Enum)
9797
.Name(Lang.Enum.Value)
9898
.Description(TypeResources.DirectiveLocation_Enum);
9999

100100
descriptor
101-
.Item(DirectiveLocation.EnumValue)
101+
.Value(DirectiveLocation.EnumValue)
102102
.Name(Lang.EnumValue.Value)
103103
.Description(TypeResources.DirectiveLocation_EnumValue);
104104

105105
descriptor
106-
.Item(DirectiveLocation.InputObject)
106+
.Value(DirectiveLocation.InputObject)
107107
.Name(Lang.InputObject.Value)
108108
.Description(TypeResources.DirectiveLocation_InputObject);
109109

110110
descriptor
111-
.Item(DirectiveLocation.InputFieldDefinition)
111+
.Value(DirectiveLocation.InputFieldDefinition)
112112
.Name(Lang.InputFieldDefinition.Value)
113113
.Description(TypeResources.DirectiveLocation_InputFieldDefinition);
114114
}

‎src/HotChocolate/Core/src/Types/Types/Introspection/__TypeKind.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,45 @@ protected override void Configure(IEnumTypeDescriptor<TypeKind> descriptor)
1515
.Description(TypeResources.TypeKind_Description)
1616
// Introspection types must always be bound explicitly so that we
1717
// do not get any interference with conventions.
18-
.BindItems(BindingBehavior.Explicit);
18+
.BindValues(BindingBehavior.Explicit);
1919

2020
descriptor
21-
.Item(TypeKind.Scalar)
21+
.Value(TypeKind.Scalar)
2222
.Name(Names.Scalar)
2323
.Description(TypeResources.TypeKind_Scalar);
2424

2525
descriptor
26-
.Item(TypeKind.Object)
26+
.Value(TypeKind.Object)
2727
.Name(Names.Object)
2828
.Description(TypeResources.TypeKind_Object);
2929

3030
descriptor
31-
.Item(TypeKind.Interface)
31+
.Value(TypeKind.Interface)
3232
.Name(Names.Interface)
3333
.Description(TypeResources.TypeKind_Interface);
3434

3535
descriptor
36-
.Item(TypeKind.Union)
36+
.Value(TypeKind.Union)
3737
.Name(Names.Union)
3838
.Description(TypeResources.TypeKind_Union);
3939

4040
descriptor
41-
.Item(TypeKind.Enum)
41+
.Value(TypeKind.Enum)
4242
.Name(Names.Enum)
4343
.Description(TypeResources.TypeKind_Enum);
4444

4545
descriptor
46-
.Item(TypeKind.InputObject)
46+
.Value(TypeKind.InputObject)
4747
.Name(Names.InputObject)
4848
.Description(TypeResources.TypeKind_InputObject);
4949

5050
descriptor
51-
.Item(TypeKind.List)
51+
.Value(TypeKind.List)
5252
.Name(Names.List)
5353
.Description(TypeResources.TypeKind_List);
5454

5555
descriptor
56-
.Item(TypeKind.NonNull)
56+
.Value(TypeKind.NonNull)
5757
.Name(Names.NonNull)
5858
.Description(TypeResources.TypeKind_NonNull);
5959
}

‎src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/EnumTypeDescriptorTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void SpecifyOneValueInferTheOthers()
5858

5959
// act
6060
IEnumTypeDescriptor desc = descriptor;
61-
desc.Item(FooEnum.Bar1).Name("FOOBAR");
61+
desc.Value(FooEnum.Bar1).Name("FOOBAR");
6262

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

8484
// act
8585
IEnumTypeDescriptor desc = descriptor;
86-
desc.Item(FooEnum.Bar1).Name("FOOBAR");
86+
desc.Value(FooEnum.Bar1).Name("FOOBAR");
8787
desc.BindValues(BindingBehavior.Explicit);
8888

8989
// assert

‎src/HotChocolate/Core/test/Types.Tests/Types/EnumTypeExtensionTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void EnumTypeExtension_AddValueThatDoesNotMatchClrType()
3333
.AddType<FooType>()
3434
.AddType(new EnumTypeExtension(d => d
3535
.Name("Foo")
36-
.Item("FOOBAR")))
36+
.Value("FOOBAR")))
3737
.Create();
3838

3939
// assert
@@ -134,8 +134,8 @@ protected override void Configure(
134134
IEnumTypeDescriptor<Foo> descriptor)
135135
{
136136
descriptor.BindValues(BindingBehavior.Explicit);
137-
descriptor.Item(Foo.Bar);
138-
descriptor.Item(Foo.Baz);
137+
descriptor.Value(Foo.Bar);
138+
descriptor.Value(Foo.Baz);
139139
}
140140
}
141141

@@ -145,7 +145,7 @@ public class FooTypeExtension
145145
protected override void Configure(IEnumTypeDescriptor descriptor)
146146
{
147147
descriptor.Name("Foo");
148-
descriptor.Item(Foo.Quox).Name("_QUOX");
148+
descriptor.Value(Foo.Quox).Name("_QUOX");
149149
}
150150
}
151151

‎src/HotChocolate/Core/test/Types.Tests/Types/EnumTypeTests.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void EnumType_DynamicName()
2222
c.RegisterType(new EnumType(d => d
2323
.Name(dep => dep.Name + "Enum")
2424
.DependsOn<StringType>()
25-
.Item("BAR")));
25+
.Value("BAR")));
2626

2727
c.Options.StrictValidation = false;
2828
});
@@ -57,7 +57,7 @@ public void EnumType_DynamicName_NonGeneric()
5757
c.RegisterType(new EnumType(d => d
5858
.Name(dep => dep.Name + "Enum")
5959
.DependsOn(typeof(StringType))
60-
.Item("BAR")));
60+
.Value("BAR")));
6161

6262
c.Options.StrictValidation = false;
6363
});
@@ -175,7 +175,7 @@ public void ExplicitEnumType_OnlyContainDeclaredValues()
175175
c.RegisterType(new EnumType<Foo>(d =>
176176
{
177177
d.BindValues(BindingBehavior.Explicit);
178-
d.Item(Foo.Bar1);
178+
d.Value(Foo.Bar1);
179179
}));
180180
c.Options.StrictValidation = false;
181181
});
@@ -198,7 +198,7 @@ public void ExplicitEnumType_OnlyContainDeclaredValues_2()
198198
c.RegisterType(new EnumType<Foo>(d =>
199199
{
200200
d.BindValuesImplicitly().BindValuesExplicitly();
201-
d.Item(Foo.Bar1);
201+
d.Value(Foo.Bar1);
202202
}));
203203
c.Options.StrictValidation = false;
204204
});
@@ -220,7 +220,7 @@ public void ImplicitEnumType_OnlyBar1HasCustomName()
220220
{
221221
c.RegisterType(new EnumType<Foo>(d =>
222222
{
223-
d.Item(Foo.Bar1).Name("FOOBAR");
223+
d.Value(Foo.Bar1).Name("FOOBAR");
224224
}));
225225
c.Options.StrictValidation = false;
226226
});
@@ -302,7 +302,7 @@ void Action() =>
302302
SchemaBuilder.New()
303303
.AddQueryType<Bar>()
304304
.AddType(new EnumType<Foo?>(d => d.Name("Foo")
305-
.Item(null)))
305+
.Value(null)))
306306
.Create();
307307

308308
// assert
@@ -328,7 +328,7 @@ public void EnumValue_WithDirectives()
328328

329329
c.RegisterType(new EnumType(d => d
330330
.Name("Foo")
331-
.Item("baz")
331+
.Value("baz")
332332
.Directive<DirectiveNode>(new DirectiveNode("bar"))));
333333

334334
c.Options.StrictValidation = false;
@@ -353,7 +353,7 @@ public void EnumValue_WithDirectivesNameArgs()
353353

354354
c.RegisterType(new EnumType(d => d
355355
.Name("Foo")
356-
.Item("baz")
356+
.Value("baz")
357357
.Directive("bar", Array.Empty<ArgumentNode>())));
358358

359359
c.Options.StrictValidation = false;
@@ -378,7 +378,7 @@ public void Serialize_EnumValue_WithDirectives()
378378

379379
c.RegisterType(new EnumType(d => d
380380
.Name("Foo")
381-
.Item("baz")
381+
.Value("baz")
382382
.Directive<DirectiveNode>(new DirectiveNode("bar"))));
383383

384384
c.Options.StrictValidation = false;
@@ -400,7 +400,7 @@ public void EnumValue_WithDirectivesT()
400400

401401
c.RegisterType(new EnumType(d => d
402402
.Name("Foo")
403-
.Item("baz")
403+
.Value("baz")
404404
.Directive<Bar>()));
405405

406406
c.Options.StrictValidation = false;
@@ -425,7 +425,7 @@ public void EnumValue_WithDirectivesTInstance()
425425

426426
c.RegisterType(new EnumType(d => d
427427
.Name("Foo")
428-
.Item("baz")
428+
.Value("baz")
429429
.Directive<Bar>(new Bar())));
430430

431431
c.Options.StrictValidation = false;

0 commit comments

Comments
 (0)
Please sign in to comment.