I dont see any major time complexity difference between these two approaches, both of them working charm, I would like to understand what is the major different between these two approach
I'm getting collection of Student object from service.
bodyToMono ParameterizedTypeReference
public Mono<Collection<Student>> getStudents(String id) {
return webClient
.get()
.uri(uriBuilder -> uriBuilder
.path("/students/{0}")
.build(id))
.retrieve()
.onStatus(HttpStatus::isError, resp -> resp.createException()
.map(WebClientGraphqlException::new)
.flatMap(Mono::error)
).bodyToMono(new ParameterizedTypeReference<Collection<Student>>() {}); // This Line
}
bodyToFlux Collectors
public Mono<Collection<Student>> getStudents(String id) {
return webClient
.get()
.uri(uriBuilder -> uriBuilder
.path("/students/{0}")
.build(id))
.retrieve()
.onStatus(HttpStatus::isError, resp -> resp.createException()
.map(WebClientGraphqlException::new)
.flatMap(Mono::error)
).bodyToFlux(Student.class).collect(Collectors.toList()); // This Line
}