-
Notifications
You must be signed in to change notification settings - Fork 329
Closed as not planned
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
I am trying to modify the BatchMapping source object right before sending back the response. Imagine there is some db/api exception while fetching ratings for a specific movie and I would like to send that exception info part of the Movie object. Below is a sample snippet and I would like to know if its achievable.
@QueryMapping(name = "getMovies")
public List getAllMovies() {
return Movie.getMovies();
}
@BatchMapping(typeName = "Movie", field = "ratings")
public Map<Movie, List<Rating>> rating(List<Movie> movies) {
// Use the context to get the batch loader
Map<Movie, List<Rating>> movieRatings = movies.stream()
.collect(Collectors.toMap(movie -> movie, movie -> Rating.getById(movie.getId())));
return movieRatings;
}
private Movie modify(Movie movie){
if(movie.getId().equalsIgnoreCase("movie-1")) { //simulating an exception
movie.setError("error while fetching ratings");
return movie;
}
return movie;
}
Metadata
Metadata
Assignees
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid