|
9 | 9 | import org.slf4j.Logger; |
10 | 10 | import org.slf4j.LoggerFactory; |
11 | 11 |
|
12 | | -import java.util.ArrayList; |
13 | | -import java.util.LinkedHashMap; |
14 | | -import java.util.List; |
15 | | -import java.util.Map; |
| 12 | +import java.util.*; |
16 | 13 |
|
17 | 14 | import static graphql.introspection.Introspection.*; |
18 | 15 |
|
@@ -62,14 +59,7 @@ protected ExecutionResult completeValue(ExecutionContext executionContext, Graph |
62 | 59 | } else if (result == null) { |
63 | 60 | return null; |
64 | 61 | } else if (fieldType instanceof GraphQLList) { |
65 | | - if (result.getClass().isArray()) { |
66 | | - List<Object> resultList = new ArrayList<>(); |
67 | | - for (Object value : (Object[]) result) { |
68 | | - resultList.add(value); |
69 | | - } |
70 | | - return completeValueForList(executionContext, (GraphQLList) fieldType, fields, resultList); |
71 | | - } |
72 | | - return completeValueForList(executionContext, (GraphQLList) fieldType, fields, (List<Object>) result); |
| 62 | + return completeValueForList(executionContext, (GraphQLList) fieldType, fields, result); |
73 | 63 | } else if (fieldType instanceof GraphQLScalarType) { |
74 | 64 | return completeValueForScalar((GraphQLScalarType) fieldType, result); |
75 | 65 | } else if (fieldType instanceof GraphQLEnumType) { |
@@ -99,6 +89,14 @@ protected ExecutionResult completeValue(ExecutionContext executionContext, Graph |
99 | 89 | return executionContext.getExecutionStrategy().execute(executionContext, resolvedType, result, subFields); |
100 | 90 | } |
101 | 91 |
|
| 92 | + private ExecutionResult completeValueForList(ExecutionContext executionContext, GraphQLList fieldType, List<Field> fields, Object result) { |
| 93 | + if (result.getClass().isArray()) { |
| 94 | + result = Arrays.asList((Object[]) result); |
| 95 | + } |
| 96 | + |
| 97 | + return completeValueForList(executionContext, fieldType, fields, (List<Object>) result); |
| 98 | + } |
| 99 | + |
102 | 100 | protected GraphQLObjectType resolveType(GraphQLInterfaceType graphQLInterfaceType, Object value) { |
103 | 101 | GraphQLObjectType result = graphQLInterfaceType.getTypeResolver().getType(value); |
104 | 102 | if (result == null) { |
|
0 commit comments