All Downloads are FREE. Search and download functionalities are using the official Maven repository.

caliban.client.ws.GraphQLWSRequest.scala Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
package caliban.client.ws

import caliban.client.GraphQLRequest
import io.circe.syntax._
import io.circe.{ Encoder, Json }

case class GraphQLWSRequest(`type`: String, id: Option[String], payload: Option[GraphQLRequest])

object GraphQLWSRequest {
  implicit val graphQLWSRequestEncoder: Encoder[GraphQLWSRequest] = (req: GraphQLWSRequest) =>
    Json.obj(
      "type"    -> Json.fromString(req.`type`),
      "id"      -> req.id.fold(Json.Null)(Json.fromString),
      "payload" -> req.payload.fold(Json.Null)(_.asJson)
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy