File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
main/java/graphql/execution/instrumentation
test/groovy/graphql/execution/instrumentation Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ public CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionRes
137
137
ExecutionResult lastResult = prevResults .size () > 0 ? prevResults .get (prevResults .size () - 1 ) : executionResult ;
138
138
return instrumentation .instrumentExecutionResult (lastResult , parameters .withNewState (state ));
139
139
});
140
- return resultsFuture .thenApply ((results ) -> results .get (results .size () - 1 ));
140
+ return resultsFuture .thenApply ((results ) -> results .isEmpty () ? executionResult : results . get (results .size () - 1 ));
141
141
}
142
142
143
143
private static class ChainedInstrumentationState implements InstrumentationState {
Original file line number Diff line number Diff line change @@ -175,6 +175,32 @@ class ChainedInstrumentationStateTest extends Specification {
175
175
176
176
}
177
177
178
+ def " empty chain" () {
179
+ def chainedInstrumentation = new ChainedInstrumentation (Arrays . asList())
180
+
181
+ def query = """
182
+ query HeroNameAndFriendsQuery {
183
+ hero {
184
+ id
185
+ }
186
+ }
187
+ """
188
+
189
+ when :
190
+ def strategy = new AsyncExecutionStrategy ()
191
+ def graphQL = GraphQL
192
+ .newGraphQL(StarWarsSchema . starWarsSchema)
193
+ .queryExecutionStrategy(strategy)
194
+ .instrumentation(chainedInstrumentation)
195
+ .build()
196
+
197
+ graphQL. execute(query)
198
+
199
+ then :
200
+ noExceptionThrown()
201
+
202
+ }
203
+
178
204
private void assertCalls (NamedInstrumentation instrumentation ) {
179
205
assert instrumentation. dfInvocations[0 ]. getFieldDefinition(). name == ' hero'
180
206
assert instrumentation. dfInvocations[0 ]. getFieldTypeInfo(). getPath(). toList() == [' hero' ]
You can’t perform that action at this time.
0 commit comments