Handling for empty representations list
Closes gh-1057
This commit is contained in:
@@ -70,6 +70,9 @@ final class EntitiesDataFetcher implements DataFetcher<Mono<DataFetcherResult<Li
|
||||
return Mono.error(new RepresentationException(
|
||||
Collections.emptyMap(), "Missing \"representations\" argument"));
|
||||
}
|
||||
if (representations.isEmpty()) {
|
||||
return Mono.just(DataFetcherResult.<List<Object>>newResult().data(Collections.emptyList()).build());
|
||||
}
|
||||
|
||||
Set<String> batchedTypes = new HashSet<>();
|
||||
List<Mono<?>> monoList = new ArrayList<>();
|
||||
|
||||
@@ -115,6 +115,14 @@ public class EntityMappingInvocationTests {
|
||||
assertAuthor(6, "George", "Orwell", helper);
|
||||
}
|
||||
|
||||
@Test // gh-1057
|
||||
void fetchEntitiesWithEmptyList() {
|
||||
Map<String, Object> vars = Map.of("representations", Collections.emptyList());
|
||||
ResponseHelper helper = executeWith(BookController.class, vars);
|
||||
|
||||
assertThat(helper.toEntity("_entities.length()", Integer.class)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@ValueSource(classes = {BookListController.class, BookFluxController.class})
|
||||
@ParameterizedTest
|
||||
void batching(Class<?> controllerClass) {
|
||||
|
||||
Reference in New Issue
Block a user