Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #40
This commit was merged in pull request #40.
This commit is contained in:
@@ -2,11 +2,14 @@ package com.drinkool.controller;
|
||||
|
||||
import com.drinkool.dtos.GraphqlDto;
|
||||
import io.smallrye.graphql.client.GraphQLClient;
|
||||
import io.smallrye.graphql.client.GraphQLError;
|
||||
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Path("/api/eatery")
|
||||
public class EateryController {
|
||||
@@ -24,9 +27,13 @@ public class EateryController {
|
||||
);
|
||||
|
||||
if (response.hasError()) {
|
||||
return jakarta.ws.rs.core.Response.status(500)
|
||||
.entity(response.getErrors())
|
||||
.build();
|
||||
List<String> errorMessages = response
|
||||
.getErrors()
|
||||
.stream()
|
||||
.map(GraphQLError::getMessage)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return Response.status(400).entity(errorMessages).build();
|
||||
}
|
||||
|
||||
return jakarta.ws.rs.core.Response.ok(
|
||||
|
||||
Reference in New Issue
Block a user