jarlakxen / drunk Goto Github PK
View Code? Open in Web Editor NEWA simple GraphQL client on top of Sangria, Akka HTTP and Circe.
License: Apache License 2.0
A simple GraphQL client on top of Sangria, Akka HTTP and Circe.
License: Apache License 2.0
Could you please publish this to maven repository on your package there is no drunk listed
https://mvnrepository.com/artifact/com.github.jarlakxen
Instead of always using Nil for Http connection headers,
AkkaHttpBackend.send()
should allow using user-defined headers.
EntityStreamSizeExceptio: actual entity size (Some(19815485)) exceeded content length limit (8388608 bytes)?
It says to configure 'akka.htttp[server|cleint].parsing.max-content-length' or calling 'HttpEntity.withZiseLimit'
Can you help how to provide above options ?
client call:: GraphQLClient(url, ConnectionsOptions.Default,ClientOptions.Default,authHeader)
The current implementation locks us into using the the AkkaBackend. A more flexible approach would be to swap it out to use STTP which has its own backend concept (one of which is Akka). For our purposes we needed such a capability so I created a spike here leadiq#1 . If the maintainers like the approach I can also open the PR to this repo so it makes it back to the mainline.
As of v2.3.0 AkkaHttpBackend.send() does not conform with the Akka doc, specifically: https://doc.akka.io/docs/akka-http/current/implications-of-streaming-http-entity.html#discarding-the-http-response-entity-client-, because it does not call discardEntityBytes()
.
Hi,
i implemented this client:
package com.github.jarlakxen.drunk
import com.github.jarlakxen.drunk.GraphQLClient.GraphQLResponse
import org.scalatest.FlatSpec
import com.github.jarlakxen.drunk.circe.deriveByTypenameDecoder
import com.typesafe.scalalogging.LazyLogging
import de.salt.d4s.model.entities.{Delivery, DeliveryItem}
import io.circe._
import io.circe.generic.semiauto._
import sangria.macros._
import java.util.concurrent.TimeUnit.MILLISECONDS
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, ExecutionContext, Future, duration}
class GraphQLSoDelClientSpec extends FlatSpec with LazyLogging {
implicit val deliveryDecoder: Decoder[Delivery] = deriveDecoder
implicit val deliveryItemDecoder: Decoder[DeliveryItem] = deriveDecoder
val duration = Duration(4000, MILLISECONDS)
//case class DeliveryQuery(delivery: Delivery)
type DeliveryQuery = Map[String, List[Delivery]]
case class Pagination(offset: Int, size: Int)
implicit val deliveryQueryDecoder: Decoder[DeliveryQuery] = deriveByTypenameDecoder()
implicit val pagniationEncoder: Encoder[Pagination] = deriveEncoder
val client = GraphQLClient(s"http://delivery-generator-mho.d4s.salt-solutions.de/graphql")
implicit val ec = ExecutionContext.global
"server" should "respond correctly to deliveryQuery" in {
val query =
graphql"""
query{delivery( id: "4727")
{
docid
docType
system
status
items{itemid product quantity unit date}}
}
"""
val page1: GraphQLCursor[DeliveryQuery, Pagination] = client.query(query, Pagination(0, 10))
val data: Future[GraphQLResponse[DeliveryQuery]] = page1.result
val result = Await.result(data, duration)
logger.debug(result.toString)
}
}
Running i get this error:
Cannot deduce decoder. Missing __typename: DownField(data)
DecodingFailure(Cannot deduce decoder. Missing __typename, List(DownField(data)))
Can anyone help me to fix it?
I am trying to use drunk for the client to make user selected requests, where vars will vary depending on what the user has selected.
Since String interpolation isn't supported yet, I tried following how variables are defined in the readme, but now I'm getting compilation error: not found: value fams
.
Here's what I'm attempting to do. ``:
families = List("ABC", "XYZ")
val query =
graphql"""
query getPeople{
getPeople(families: [$fams]) {
name
}
}
"""
val vars = Map("fams" -> families.mkString("\"", "\",\"", "\"")
val result = client.query[List[People],Map[String,String]](query, vars)
If I skip variable definitions, and just hardcode the families input, I'm still getting an error about a decoder missing:
could not find implicit value for parameter dec: io.circe.Decoder[List[People]]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.