Skip to content

Commit

Permalink
Prevented type descriptions from being overwritten while merging (#7751)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Nov 21, 2024
1 parent 3681f75 commit a8b5c8e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected void MergeInto(DefinitionBase target)
}
}

if (Description is not null)
if (target.Description is null && Description is not null)
{
target.Description = Description;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HotChocolate.Types.Descriptors;

/// <summary>
/// QueryExtWithDocs1
/// </summary>
[QueryType]
public static class QueryExtWithDocs1
{
public static int GetFoo1() => 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HotChocolate.Types.Descriptors;

/// <summary>
/// QueryExtWithDocs2
/// </summary>
[QueryType]
public static class QueryExtWithDocs2
{
public static int GetFoo2() => 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using CookieCrumble;
using HotChocolate.Execution;
using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Types.Descriptors.Definitions;

public class DefinitionBaseTests
{
[Fact]
public async Task MergeInto_MultipleTypeExtensionXmlDescriptions_UsesQueryTypeDescription()
{
// arrange & act
var schema = await new ServiceCollection()
.AddGraphQL()
.AddQueryType(d => d.Description("Query"))
.AddTypeExtension(typeof(QueryExtWithDocs1))
.AddTypeExtension(typeof(QueryExtWithDocs2))
.BuildSchemaAsync();

// assert
schema.MatchInlineSnapshot(
"""
schema {
query: Query
}

"Query"
type Query {
foo1: Int!
foo2: Int!
}
""");
}
}

0 comments on commit a8b5c8e

Please sign in to comment.