Skip to content

Commit

Permalink
Handling for empty representations list
Browse files Browse the repository at this point in the history
Closes gh-1057
  • Loading branch information
rstoyanchev committed Sep 17, 2024
1 parent ba1dcf0 commit c340d85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public Mono<DataFetcherResult<List<Object>>> get(DataFetchingEnvironment env) {
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<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ void fetchEntitiesWithExceptions() {
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) {
Expand Down

0 comments on commit c340d85

Please sign in to comment.