File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed
test/Execution.Tests/Integration/DataLoader Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ private static void CreateNodeField(
94
94
} ;
95
95
} ) ,
96
96
} ,
97
- Flags = FieldFlags . GlobalIdNodeField
97
+ Flags = FieldFlags . ParallelExecutable | FieldFlags . GlobalIdNodeField
98
98
} ;
99
99
100
100
// In the projection interceptor we want to change the context data that is on this field
@@ -134,7 +134,7 @@ private static void CreateNodesField(
134
134
} ;
135
135
} ) ,
136
136
} ,
137
- Flags = FieldFlags . GlobalIdNodesField
137
+ Flags = FieldFlags . ParallelExecutable | FieldFlags . GlobalIdNodesField
138
138
} ;
139
139
140
140
// In the projection interceptor we want to change the context data that is on this field
Original file line number Diff line number Diff line change @@ -59,6 +59,43 @@ await ExpectValid(
59
59
await snapshot . MatchMarkdownAsync ( ) ;
60
60
}
61
61
62
+ [ Fact ]
63
+ public async Task FetchMultipleNodesDataLoader ( )
64
+ {
65
+ var batchFetchCount = 0 ;
66
+
67
+ await ExpectValid (
68
+ """
69
+ {
70
+ a: node(id: "RW50aXR5OjE==") { ... on Entity { id } }
71
+ b: node(id: "RW50aXR5OjI==") { ... on Entity { id } }
72
+ }
73
+ """ ,
74
+ configure : b => b
75
+ . AddGraphQL ( )
76
+ . AddGlobalObjectIdentification ( )
77
+ . AddObjectType < Entity > ( descriptor =>
78
+ {
79
+ descriptor
80
+ . ImplementsNode ( )
81
+ . IdField ( e => e . Id )
82
+ . ResolveNode (
83
+ async ( ctx , id ) => await ctx . BatchDataLoader < int , Entity > (
84
+ ( keys , _ ) =>
85
+ {
86
+ batchFetchCount ++ ;
87
+
88
+ return Task . FromResult < IReadOnlyDictionary < int , Entity > > (
89
+ keys . ToDictionary ( t => t , _ => new Entity { Id = id } ) ) ;
90
+ } )
91
+ . LoadAsync ( id ) )
92
+ . Resolve ( ctx => ctx . Parent < Entity > ( ) . Id ) ;
93
+ } )
94
+ . AddQueryType ( ) ) ;
95
+
96
+ Assert . Equal ( 1 , batchFetchCount ) ;
97
+ }
98
+
62
99
[ LocalFact ]
63
100
public async Task FetchDataLoader ( )
64
101
{
@@ -667,4 +704,9 @@ public CounterDataLoader(DataLoaderOptions options) : base(options)
667
704
protected override Task < string > LoadSingleAsync ( string key , CancellationToken cancellationToken )
668
705
=> Task . FromResult ( key + Counter ) ;
669
706
}
707
+
708
+ public class Entity
709
+ {
710
+ public int Id { get ; set ; }
711
+ }
670
712
}
You can’t perform that action at this time.
0 commit comments