fix: better graphql response type for native (#43)
Release package / release (push) Successful in 19m0s
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:
@@ -10,6 +10,9 @@ import jakarta.ws.rs.core.Context;
|
|||||||
import jakarta.ws.rs.core.HttpHeaders;
|
import jakarta.ws.rs.core.HttpHeaders;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
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")
|
@Path("/api/eatery")
|
||||||
public class EateryController {
|
public class EateryController {
|
||||||
@@ -17,6 +20,9 @@ public class EateryController {
|
|||||||
@ConfigProperty(name = "quarkus.smallrye-graphql-client.eatery.url")
|
@ConfigProperty(name = "quarkus.smallrye-graphql-client.eatery.url")
|
||||||
String eateryUrl;
|
String eateryUrl;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Jsonb jsonb;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/graphql")
|
@Path("/graphql")
|
||||||
public Response forward(
|
public Response forward(
|
||||||
@@ -45,10 +51,12 @@ public class EateryController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.hasError()) {
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return Response.serverError()
|
return Response.serverError()
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
mvn clean package -DskipTests \
|
mvn clean package -DskipTests \
|
||||||
-Dquarkus.container-image.push=false \
|
-Dquarkus.container-image.push=false \
|
||||||
-Dquarkus.container-image.registry=git.demonkernel.io.vn
|
-Dquarkus.container-image.registry=git.demonkernel.io.vn \
|
||||||
|
"$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user