Skip to content

Commit 6473ae8

Browse files
committed
Fixed Node id field can no longer be provided via an extension type (#8116)
1 parent 8dadf9a commit 6473ae8

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

src/HotChocolate/Core/src/Types/Types/Relay/Attributes/NodeAttribute.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,6 @@ protected override void OnConfigure(
141141
nodeDescriptor.TryResolveNode(type);
142142
}
143143

144-
// we trigger a late id field configuration
145-
var typeDescriptor = ObjectTypeDescriptor.From(
146-
completionContext.DescriptorContext,
147-
definition);
148-
nodeDescriptor.ConfigureNodeField(typeDescriptor);
149-
typeDescriptor.CreateDefinition();
150-
151144
// invoke completion explicitly.
152145
nodeDescriptor.OnCompleteDefinition(completionContext, definition);
153146
});

src/HotChocolate/Core/test/Types.Tests/Types/Relay/NodeResolverTests.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,26 @@ ... on Entity {
251251
.MatchSnapshotAsync();
252252
}
253253

254+
// Ensure Issue 7829 is fixed.
255+
[Fact]
256+
public async Task NodeAttribute_On_Extension_With_Renamed_Id()
257+
{
258+
await new ServiceCollection()
259+
.AddGraphQL()
260+
.AddQueryType<QueryEntityRenamed>()
261+
.AddTypeExtension<EntityExtensionRenamingId>()
262+
.ExecuteRequestAsync(
263+
"""
264+
{
265+
entity(id: 5) {
266+
id
267+
data
268+
}
269+
}
270+
""")
271+
.MatchSnapshotAsync();
272+
}
273+
254274
public class Query
255275
{
256276
public Entity GetEntity(string name) => new Entity { Name = name, };
@@ -330,5 +350,28 @@ public class EntityExtension4
330350
{
331351
public static Entity GetEntity(string id) => new() { Name = id, };
332352
}
353+
354+
public class QueryEntityRenamed
355+
{
356+
public EntityNoId GetEntity(int id)
357+
=> new EntityNoId { Data = id };
358+
}
359+
360+
public class EntityNoId
361+
{
362+
public int Data { get; set; }
363+
}
364+
365+
[Node]
366+
[ExtendObjectType(typeof(EntityNoId))]
367+
public class EntityExtensionRenamingId
368+
{
369+
public int GetId([Parent] EntityNoId entity)
370+
=> entity.Data;
371+
372+
[NodeResolver]
373+
public EntityNoId GetEntity(int id)
374+
=> new() { Data = id, };
375+
}
333376
}
334377
#pragma warning restore RCS1102 // Make class static
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"data": {
3+
"entity": {
4+
"id": "RW50aXR5Tm9JZDo1",
5+
"data": 5
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)