Skip to content

Commit b81c373

Browse files
authored
Updated IntrospectionFormatter to set default deprecation reason (#8752)
1 parent a33a13c commit b81c373

File tree

4 files changed

+1159
-1
lines changed

4 files changed

+1159
-1
lines changed

src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,16 @@ private static IReadOnlyList<NamedTypeNode> CreateNamedTypeRefs(
317317
}
318318

319319
private static IReadOnlyList<DirectiveNode> CreateDeprecatedDirective(
320-
bool isDeprecated, string deprecationReason)
320+
bool isDeprecated,
321+
string deprecationReason)
321322
{
323+
const string defaultReason = "No longer supported.";
324+
325+
if (string.IsNullOrEmpty(deprecationReason))
326+
{
327+
deprecationReason = defaultReason;
328+
}
329+
322330
if (isDeprecated)
323331
{
324332
return new List<DirectiveNode>

src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/IntrospectionFormatterTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,18 @@ public void DeserializeIntrospectionWithIntDefaultValues()
3232
// assert
3333
schema.ToString(true).MatchSnapshot();
3434
}
35+
36+
[Fact]
37+
public void DeserializeIntrospectionWithNullDeprecationReason()
38+
{
39+
// arrange
40+
var json = FileResource.Open("IntrospectionWithNullDeprecationReason.json");
41+
var result = JsonSerializer.Deserialize<IntrospectionResult>(json, SerializerOptions);
42+
43+
// act
44+
var schema = IntrospectionFormatter.Format(result!);
45+
46+
// assert
47+
schema.ToString(true).MatchSnapshot();
48+
}
3549
}

0 commit comments

Comments
 (0)