|
29 | 29 | import org.slf4j.Logger; |
30 | 30 | import org.slf4j.LoggerFactory; |
31 | 31 |
|
| 32 | +import java.lang.reflect.Array; |
32 | 33 | import java.util.ArrayList; |
33 | | -import java.util.Arrays; |
34 | 34 | import java.util.List; |
35 | 35 | import java.util.Map; |
36 | 36 | import java.util.Optional; |
37 | 37 | import java.util.concurrent.CompletableFuture; |
38 | 38 | import java.util.concurrent.CompletionException; |
39 | 39 | import java.util.concurrent.CompletionStage; |
| 40 | +import java.util.stream.IntStream; |
40 | 41 |
|
41 | 42 | import static graphql.execution.ExecutionTypeInfo.newTypeInfo; |
42 | 43 | import static graphql.execution.FieldCollectorParameters.newParameters; |
|
45 | 46 | import static graphql.introspection.Introspection.TypeNameMetaFieldDef; |
46 | 47 | import static graphql.schema.DataFetchingEnvironmentBuilder.newDataFetchingEnvironment; |
47 | 48 | import static java.util.concurrent.CompletableFuture.completedFuture; |
| 49 | +import static java.util.stream.Collectors.toList; |
48 | 50 |
|
49 | 51 | /** |
50 | 52 | * An execution strategy is give a list of fields from the graphql query to execute and find values for using a recursive strategy. |
@@ -401,7 +403,9 @@ private Object unboxPossibleOptional(Object result) { |
401 | 403 |
|
402 | 404 | private Iterable<Object> toIterable(Object result) { |
403 | 405 | if (result.getClass().isArray()) { |
404 | | - result = Arrays.asList((Object[]) result); |
| 406 | + return IntStream.range(0, Array.getLength(result)) |
| 407 | + .mapToObj(i -> Array.get(result, i)) |
| 408 | + .collect(toList()); |
405 | 409 | } |
406 | 410 | //noinspection unchecked |
407 | 411 | return (Iterable<Object>) result; |
|
0 commit comments