Skip to content
Draft
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 @@ -35,6 +35,11 @@ protected FilterFieldDescriptor(
Configuration.Description = convention.GetFieldDescription(member);
Configuration.Type = convention.GetFieldType(member);
Configuration.Scope = scope;

if (context.Naming.IsDeprecated(member, out var reason))
{
Deprecated(reason);
}
}

protected FilterFieldDescriptor(
Expand Down
5 changes: 5 additions & 0 deletions src/HotChocolate/Data/src/Data/Sorting/SortFieldDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ protected SortFieldDescriptor(IDescriptorContext context, string? scope, MemberI
Configuration.Type = convention.GetFieldType(member);
Configuration.Scope = scope;
Configuration.Flags = CoreFieldFlags.SortOperationField;

if (context.Naming.IsDeprecated(member, out var reason))
{
Deprecated(reason);
}
}

protected internal SortFieldDescriptor(IDescriptorContext context, string? scope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,18 @@ public async Task Execute_CoerceWhereArgument_MatchesSnapshot()
result.MatchSnapshot();
}

[Fact]
public void FilterInputType_ShouldInferDeprecatedDirective_ForDeprecatedFields()
{
// arrange
// act
var schema = CreateSchema(
s => s.AddType(new FilterInputType<TypeWithDeprecatedField>()));

// assert
schema.MatchSnapshot();
}

public class FooDirectiveType
: DirectiveType<FooDirective>
{
Expand Down Expand Up @@ -608,4 +620,8 @@ public class FilterWithStruct
}

public record struct ExampleValueType(string Foo, string Bar);

public record TypeWithDeprecatedField(
string Foo,
[property: GraphQLDeprecated("old")] string? DeprecatedField = null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
schema {
query: Query
}

type Query {
foo: String
}

input StringOperationFilterInput {
and: [StringOperationFilterInput!]
or: [StringOperationFilterInput!]
eq: String
neq: String
contains: String
ncontains: String
in: [String]
nin: [String]
startsWith: String
nstartsWith: String
endsWith: String
nendsWith: String
}

input TypeWithDeprecatedFieldFilterInput {
and: [TypeWithDeprecatedFieldFilterInput!]
or: [TypeWithDeprecatedFieldFilterInput!]
foo: StringOperationFilterInput
deprecatedField: StringOperationFilterInput @deprecated(reason: "old")
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ public void SortInputType_Should_InfereType_When_ItIsAInterface()
schema.ToString().MatchSnapshot();
}

[Fact]
public void SortInputType_ShouldInferDeprecatedDirective_ForDeprecatedFields()
{
// arrange
// act
var schema = CreateSchema(
s => s.AddType(new SortInputType<TypeWithDeprecatedField>()));

// assert
schema.MatchSnapshot();
}

public class IgnoreTest
{
public int Id { get; set; }
Expand Down Expand Up @@ -368,4 +380,8 @@ protected override void Configure(IObjectTypeDescriptor<TestObject<T>> descripto
descriptor.Field(x => x.Root).UseFiltering();
}
}

public record TypeWithDeprecatedField(
string Foo,
[property: GraphQLDeprecated("old")] string? DeprecatedField = null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
schema {
query: Query
}

type Query {
foo: String
}

input TypeWithDeprecatedFieldSortInput {
foo: SortEnumType
deprecatedField: SortEnumType @deprecated(reason: "old")
}

enum SortEnumType {
ASC
DESC
}