fix: better graphql response type for native (#43)
Release package / release (push) Successful in 19m0s

Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com>
Reviewed-on: #43
This commit was merged in pull request #43.
This commit is contained in:
2026-05-05 03:58:02 +00:00
parent 01e2ad966a
commit b401627506
2 changed files with 12 additions and 3 deletions
@@ -10,6 +10,9 @@ import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import jakarta.inject.Inject;
import jakarta.json.bind.Jsonb;
import jakarta.ws.rs.core.MediaType;
@Path("/api/eatery")
public class EateryController {
@@ -17,6 +20,9 @@ public class EateryController {
@ConfigProperty(name = "quarkus.smallrye-graphql-client.eatery.url")
String eateryUrl;
@Inject
Jsonb jsonb;
@POST
@Path("/graphql")
public Response forward(
@@ -45,10 +51,12 @@ public class EateryController {
);
if (response.hasError()) {
return Response.status(400).entity(response.getErrors()).build();
return Response.status(400).entity(jsonb.toJson(response.getErrors())).build();
}
return Response.ok(response.getData()).build();
return Response.ok(jsonb.toJson(response.getData()))
.type(MediaType.APPLICATION_JSON)
.build();
} catch (Exception e) {
e.printStackTrace();
return Response.serverError()