Skip to content

Commit 06bcb6a

Browse files
committed
Fixed Issue with Field Deprecations on Type Extensions
1 parent 0f8aef6 commit 06bcb6a

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/QueryExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ public async Task<bool> Wait(int m, CancellationToken ct)
2121
await Task.Delay(m, ct);
2222
return true;
2323
}
24+
25+
[GraphQLDeprecated("use something else")]
26+
public string SomeDeprecatedField(
27+
[GraphQLDeprecated("use something else")]
28+
string deprecatedArg = "foo")
29+
=> "foo";
2430
}

src/HotChocolate/Core/src/Types/Types/Descriptors/Definitions/FieldDefinitionBase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ protected void CopyTo(FieldDefinitionBase target)
109109

110110
target.Type = Type;
111111
target.Ignore = Ignore;
112+
113+
if (IsDeprecated)
114+
{
115+
target.DeprecationReason = DeprecationReason;
116+
}
112117
}
113118

114119
protected void MergeInto(FieldDefinitionBase target)
@@ -127,5 +132,10 @@ protected void MergeInto(FieldDefinitionBase target)
127132
}
128133

129134
target.Ignore = Ignore;
135+
136+
if (IsDeprecated)
137+
{
138+
target.DeprecationReason = DeprecationReason;
139+
}
130140
}
131141
}

src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionOptions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ public int TypeDepth
4343
if (value < 3)
4444
{
4545
throw new ArgumentOutOfRangeException(
46-
nameof(TypeDepth),
47-
value,
46+
nameof(TypeDepth),
47+
value,
4848
IntrospectionOptions_MinTypeDepth);
49-
}
50-
49+
}
50+
5151
_typeDepth = value;
5252
}
5353
}
5454

5555
public bool Equals(IntrospectionOptions other)
56-
=> Equals(_method, other._method) &&
57-
Equals(_typeDepth, other._typeDepth) &&
58-
Equals(Uri, other.Uri) &&
59-
ReferenceEquals(OnMessageCreated, other.OnMessageCreated);
60-
56+
=> Equals(_method, other._method)
57+
&& Equals(_typeDepth, other._typeDepth)
58+
&& Equals(Uri, other.Uri)
59+
&& ReferenceEquals(OnMessageCreated, other.OnMessageCreated);
60+
6161
public override bool Equals(object? obj)
6262
=> obj is IntrospectionOptions options && Equals(options);
6363

@@ -69,4 +69,4 @@ public override int GetHashCode()
6969

7070
public static bool operator !=(IntrospectionOptions left, IntrospectionOptions right)
7171
=> !(left == right);
72-
}
72+
}

src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/__snapshots__/IntrospectionClientTests.IntrospectServer_NET6.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Query {
1515
time: Long!
1616
evict: Boolean!
1717
wait(m: Int!): Boolean!
18+
someDeprecatedField(deprecatedArg: String! = "foo" @deprecated(reason: "use something else")): String! @deprecated(reason: "use something else")
1819
}
1920

2021
type Mutation {

0 commit comments

Comments
 (0)