I wanted to test my Caliban Http4s Webservice.
In Http4sAdapter
it uses GraphQLRequest
to model a Request Body.
case class GraphQLRequest(
query: String,
operationName: Option[String],
variables: Option[Map[String, InputValue]])
...
query <- req.attemptAs[GraphQLRequest].value.absolve
...
So I thought on the client side I could use it as well.
A simple Request works:
GraphQLRequest("""query{
| characters(origin: EARTH) {
| name
| nicknames
| origin
| }
|}""".stripMargin, None, None)
But if I use variables it doesn't:
GraphQLRequest("""query($origin: String){
| characters(origin: $origin) {
| name
| nicknames
| origin
| }
|}""".stripMargin, None, Some(Map("origin" -> StringValue("EARTH"))))
It just hangs - there is not even an exception.
I tried with 0.4.2
and 0.5.0
.
I added a Gist to show the client code. It uses Circe and Sttp: Client Gist