I'm trying to build a camel route to consume the message from ActiveMQ and extract some JSON fields and send the extracted payload to graphql server. I followed graphql component documentation, however, I was unable to figure out how to get the variable values dynamically from the exchange.
# bookByIdQuery.graphql
query($id : String!) {
book(id :$id) {
id
name
}
}
@BindToRegistry("bookByIdQueryVariables")
public JsonObject bookByIdQueryVariables() {
JsonObject variables = new JsonObject();
variables.put("id", "book-1");
return variables;
}
from("direct:start")
.to("graphql://http://example.com/graphql?queryFile=bookByIdQuery.graphql&variables=#bookByIdQueryVariables")
In the above example, I want to get the variable value from the exchange. I mean book-1 I need to get from exchange. For that, I made the method to accept the exchange as a parameter, however it does not replace the values in the query. I tried to debug and seen the exchange as null and bookByIdQueryVariables bean is found in context. Seems like there is no converter to convert the bookByIdQueryVariables type to a JSON object. Please suggest if there is a problem in graphql query or variable bean. Any help is appreciated