1
1
#pragma warning disable RCS1102 // Make class static
2
2
using HotChocolate . Execution ;
3
+ using HotChocolate . Execution . Processing ;
3
4
using HotChocolate . Language ;
4
5
using HotChocolate . Tests ;
5
6
using HotChocolate . Types . Relay ;
@@ -271,6 +272,33 @@ public async Task NodeAttribute_On_Extension_With_Renamed_Id()
271
272
. MatchSnapshotAsync ( ) ;
272
273
}
273
274
275
+ [ Fact ]
276
+ public async Task NodeResolver_And_AsSelector ( )
277
+ {
278
+ // arrange
279
+ var executor =
280
+ await new ServiceCollection ( )
281
+ . AddGraphQLServer ( )
282
+ . AddGlobalObjectIdentification ( )
283
+ . AddTypeExtension < EntityExtension5 > ( )
284
+ . AddTypeExtension < Entity2Extension1 > ( )
285
+ . AddQueryType < Query > ( )
286
+ . BuildRequestExecutorAsync ( ) ;
287
+
288
+ // act
289
+ var result = await executor . ExecuteAsync (
290
+ """
291
+ {
292
+ nodes(ids: ["RW50aXR5OmZvbw=="]) {
293
+ id
294
+ }
295
+ }
296
+ """ ) ;
297
+
298
+ // assert
299
+ Assert . Null ( result . ExpectOperationResult ( ) . Errors ) ;
300
+ }
301
+
274
302
public class Query
275
303
{
276
304
public Entity GetEntity ( string name ) => new Entity { Name = name , } ;
@@ -292,7 +320,12 @@ protected override void Configure(
292
320
293
321
public class Entity
294
322
{
295
- public string Id => Name ;
323
+ public string Id
324
+ {
325
+ get => Name ;
326
+ set => Name = value ;
327
+ }
328
+
296
329
public string Name { get ; set ; }
297
330
}
298
331
@@ -351,6 +384,32 @@ public class EntityExtension4
351
384
public static Entity GetEntity ( string id ) => new ( ) { Name = id , } ;
352
385
}
353
386
387
+ [ Node ]
388
+ [ ExtendObjectType ( typeof ( Entity ) ) ]
389
+ public class EntityExtension5
390
+ {
391
+ [ NodeResolver ]
392
+ public static Entity GetEntity ( string id , ISelection selection )
393
+ {
394
+ selection . AsSelector < Entity > ( ) ;
395
+
396
+ return new Entity { Name = id , } ;
397
+ }
398
+ }
399
+
400
+ [ Node ]
401
+ [ ExtendObjectType ( typeof ( Entity2 ) ) ]
402
+ public class Entity2Extension1
403
+ {
404
+ [ NodeResolver ]
405
+ public static Entity2 GetEntity2 ( string id , ISelection selection )
406
+ {
407
+ selection . AsSelector < Entity2 > ( ) ;
408
+
409
+ return new Entity2 { Name = id , } ;
410
+ }
411
+ }
412
+
354
413
public class QueryEntityRenamed
355
414
{
356
415
public EntityNoId GetEntity ( int id )
0 commit comments