Caliban GitHub GraphQL API Client

Build Maven Central

Scala GitHub GraphQL API Library based upon Caliban: Caliban is a purely functional library for building GraphQL servers and clients in Scala.

Usage

The packages are published on Maven Central.

libraryDependencies += "io.github.er1c" %% "caliban-github-api-client" % "<version>"

Example

package examples.packages

import caliban.client.github.Client
import sttp.client._
import sttp.client.asynchttpclient.zio.{AsyncHttpClientZioBackend, SttpClient}
import sttp.model.Header
import zio._
import zio.console._

object Main extends App {
  override def run(args: List[String]): ZIO[zio.ZEnv, Nothing, ExitCode] = {
    import Client._

    val license = {
      import License._
      id ~
        key ~
        name
    }

    val query = Query.licenses {
      license
    }

    val uri = uri"https://api.github.com/graphql"

    SttpClient
      .send(query.toRequest(uri).headers(Header("Authorization", "Bearer " + sys.env("GITHUB_TOKEN"))))
      .map(_.body)
      .absolve
      .tap(res => putStrLn(s"Result: $res"))
      .provideCustomLayer(AsyncHttpClientZioBackend.layer())
      .foldM(ex => putStrLn(ex.toString).as(ExitCode.failure), _ => ZIO.succeed(ExitCode.success))
  }
}

Documentation

Links:

Contributing

The Scala GitHub GraphQL API Library project welcomes contributions from anybody wishing to participate. All code or documentation that is provided must be licensed with the same license that Scala GitHub GraphQL API Library is licensed with (Apache 2.0, see LICENCE).

People are expected to follow the Scala Code of Conduct when discussing Scala GitHub GraphQL API Library on GitHub, Gitter channel, or other venues.

Feel free to open an issue if you notice a bug, have an idea for a feature, or have a question about the code. Pull requests are also gladly accepted. For more information, check out the contributor guide.

License

All code in this repository is licensed under the Apache License, Version 2.0. See LICENCE.