I am currently creating a POC. We have a proxy lambda linked up to an API gateway. This Lambda access some data and returns films. These items are very large, so we would like to give customers the ability to filter which attributes they get from the items. We would like to do this using graphql. I am also using quarkus and java following this tutorial. https://quarkus.io/guides/smallrye-graphql
I was thinking that by using graphql I could make a resource like
@GraphQLApi
public class FilmResource {
@Inject
GalaxyService service;
@Query("allFilms")
@Description("Get all Films from a galaxy far far away")
public List<Film> getAllFilms() {
return service.getAllFilms();
}
@Query
@Description("Get a Films from a galaxy far far away")
public Film getFilm(@Name("filmId") int id) {
return service.getFilm(id);
}
}
An aws proxy lambda accepts a type of APIGatewayProxyRequestEvent
which has a String body
. I was hoping I could wrap FilmResource.java
in a graphql client and directly apply the body of an APIGatewayProxyEvent to the Film Resource.
This would look something like this
@Named("test")
public class TestLambda implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
@Inject
FilmResource resource;
@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent awsLambdaEvent, Context context) {
DynamicGraphQLClient client = DynamicGraphQLClientBuilder.newBuilder().client(resource).build();
JsonObject data = client.executeSync(awsLambdaEvent.getBody()).getData();
return new APIGatewayProxyResponseEvent().withBody(data.toString()).withStatusCode(200);
}
}
So Ideally, the customer would be able to pass the below query to the lambda, and it would receive the correct response.
query allFilms {
allFilms {
title
releaseDate
}
}
However, it seems like all the clients only work with remote graphql servers. Is there a client that can wrap an internal graphql server class? Source: https://quarkus.io/guides/smallrye-graphql-client