Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #4

Merged
merged 3 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
lazy val catsEffectVersion = "1.1.0"
lazy val catsVersion = "1.5.0"
lazy val circeVersion = "0.10.0"
lazy val doobieVersion = "0.6.0"
lazy val fs2Version = "1.0.2"
lazy val kindProjectorVersion = "0.9.9"
lazy val log4catsVersion = "0.2.0"
lazy val sangriaCirceVersion = "1.2.1"
lazy val catsEffectVersion = "2.1.3"
lazy val catsVersion = "2.1.1"
lazy val circeVersion = "0.13.0"
lazy val doobieVersion = "0.9.0"
lazy val fs2Version = "2.3.0"
lazy val kindProjectorVersion = "0.9.10"
lazy val log4catsVersion = "1.0.1"
lazy val sangriaCirceVersion = "1.3.0"
lazy val sangriaVersion = "1.4.2"
lazy val scala12Version = "2.12.8"
lazy val http4sVersion = "0.20.0-M4"
lazy val slf4jVersion = "1.7.25"
lazy val scala12Version = "2.12.11"
lazy val http4sVersion = "0.21.4"
lazy val slf4jVersion = "1.7.30"

lazy val scalacSettings = Seq(
scalacOptions ++=
Expand Down
21 changes: 11 additions & 10 deletions modules/core/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import org.http4s.implicits._
import org.http4s.server.Server
import org.http4s.server.blaze._
import scala.concurrent.ExecutionContext
import scala.concurrent.ExecutionContext.global

object Main extends IOApp {

// Construct a transactor for connecting to the database.
def transactor[F[_]: Async: ContextShift](
bec: ExecutionContext
blocker: Blocker
): Resource[F, HikariTransactor[F]] =
ExecutionContexts.fixedThreadPool[F](10).flatMap { ce =>
HikariTransactor.newHikariTransactor(
Expand All @@ -37,7 +38,7 @@ object Main extends IOApp {
"user",
"password",
ce,
bec
blocker
)
}

Expand All @@ -58,14 +59,14 @@ object Main extends IOApp {

// Playground or else redirect to playground
def playgroundOrElse[F[_]: Sync: ContextShift](
blockingContext: ExecutionContext
blocker: Blocker
): HttpRoutes[F] = {
object dsl extends Http4sDsl[F]; import dsl._
HttpRoutes.of[F] {

case GET -> Root / "playground.html" =>
StaticFile
.fromResource[F]("/assets/playground.html", blockingContext)
.fromResource[F]("/assets/playground.html", blocker)
.getOrElseF(NotFound())

case _ =>
Expand All @@ -78,7 +79,7 @@ object Main extends IOApp {
def server[F[_]: ConcurrentEffect: ContextShift: Timer](
routes: HttpRoutes[F]
): Resource[F, Server[F]] =
BlazeServerBuilder[F]
BlazeServerBuilder[F](global)
.bindHttp(8080, "localhost")
.withHttpApp(routes.orNotFound)
.resource
Expand All @@ -88,16 +89,16 @@ object Main extends IOApp {
implicit L: Logger[F]
): Resource[F, Server[F]] =
for {
bec <- ExecutionContexts.cachedThreadPool[F]
xa <- transactor[F](bec)
gql = graphQL[F](xa, bec)
rts = GraphQLRoutes[F](gql) <+> playgroundOrElse(bec)
b <- Blocker[F]
xa <- transactor[F](b)
gql = graphQL[F](xa, b.blockingContext)
rts = GraphQLRoutes[F](gql) <+> playgroundOrElse(b)
svr <- server[F](rts)
} yield svr

// Our entry point starts the server and blocks forever.
def run(args: List[String]): IO[ExitCode] = {
implicit val log = Slf4jLogger.unsafeCreate[IO]
implicit val log = Slf4jLogger.getLogger[IO]
resource[IO].use(_ => IO.never.as(ExitCode.Success))
}

Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/main/scala/repo/CityRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package demo.repo

import cats._
import cats.effect._
import cats.implicits._
import doobie._
import doobie.implicits._
Expand All @@ -18,7 +18,7 @@ trait CityRepo[F[_]] {

object CityRepo {

def fromTransactor[F[_]: Monad: Logger](xa: Transactor[F]): CityRepo[F] =
def fromTransactor[F[_]: Sync: Logger](xa: Transactor[F]): CityRepo[F] =
new CityRepo[F] {

val select: Fragment =
Expand All @@ -37,4 +37,4 @@ object CityRepo {

}

}
}
6 changes: 3 additions & 3 deletions modules/core/src/main/scala/repo/CountryRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package demo.repo

import cats._
import cats.data._
import cats.effect._
import cats.implicits._
import doobie._
import doobie.implicits._
Expand All @@ -21,7 +21,7 @@ trait CountryRepo[F[_]] {

object CountryRepo {

def fromTransactor[F[_]: Monad: Logger](xa: Transactor[F]): CountryRepo[F] =
def fromTransactor[F[_]: Sync: Logger](xa: Transactor[F]): CountryRepo[F] =
new CountryRepo[F] {

val select: Fragment =
Expand Down Expand Up @@ -56,4 +56,4 @@ object CountryRepo {

}

}
}
6 changes: 3 additions & 3 deletions modules/core/src/main/scala/repo/LanguageRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package demo.repo

import cats._
import cats.data._
import cats.effect.Sync
import cats.implicits._
import doobie._
import doobie.implicits._
Expand All @@ -19,7 +19,7 @@ trait LanguageRepo[F[_]] {

object LanguageRepo {

def fromTransactor[F[_]: Monad: Logger](xa: Transactor[F]): LanguageRepo[F] =
def fromTransactor[F[_]: Sync: Logger](xa: Transactor[F]): LanguageRepo[F] =
new LanguageRepo[F] {

val select: Fragment =
Expand Down Expand Up @@ -51,4 +51,4 @@ object LanguageRepo {

}

}
}
6 changes: 3 additions & 3 deletions modules/core/src/main/scala/repo/MasterRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package demo.repo

import cats._
import cats.effect._
import doobie._
import io.chrisdavenport.log4cats.Logger

Expand All @@ -16,11 +16,11 @@ final case class MasterRepo[F[_]](

object MasterRepo {

def fromTransactor[F[_]: Monad: Logger](xa: Transactor[F]): MasterRepo[F] =
def fromTransactor[F[_]: Sync: Logger](xa: Transactor[F]): MasterRepo[F] =
MasterRepo(
CityRepo.fromTransactor(xa),
CountryRepo.fromTransactor(xa),
LanguageRepo.fromTransactor(xa)
)

}
}
33 changes: 16 additions & 17 deletions modules/core/src/main/scala/sangria/SangriaGraphQL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import _root_.sangria.marshalling.circe._
import _root_.sangria.parser.{ QueryParser, SyntaxError }
import _root_.sangria.schema._
import _root_.sangria.validation._
import cats._
import cats.effect._
import cats.implicits._
import io.circe.{ Json, JsonObject }
Expand Down Expand Up @@ -70,8 +69,7 @@ object SangriaGraphQL {
userContext: F[A],
blockingExecutionContext: ExecutionContext
)(
implicit F: MonadError[F, Throwable],
L: LiftIO[F]
implicit F: Async[F],
): GraphQL[F] =
new GraphQL[F] {

Expand Down Expand Up @@ -107,21 +105,22 @@ object SangriaGraphQL {
variables: JsonObject
)(implicit ec: ExecutionContext): F[Either[Json, Json]] =
userContext.flatMap { ctx =>
IO.fromFuture {
IO {
Executor.execute(
schema = schema,
deferredResolver = deferredResolver,
queryAst = query,
userContext = ctx,
variables = Json.fromJsonObject(variables),
operationName = operationName,
exceptionHandler = ExceptionHandler {
case (_, e) ⇒ HandledException(e.getMessage)
}
)
F.async { (cb: Either[Throwable, Json] => Unit) =>
Executor.execute(
schema = schema,
deferredResolver = deferredResolver,
queryAst = query,
userContext = ctx,
variables = Json.fromJsonObject(variables),
operationName = operationName,
exceptionHandler = ExceptionHandler {
case (_, e) ⇒ HandledException(e.getMessage)
}
).onComplete {
case Success(value) => cb(Right(value))
case Failure(error) => cb(Left(error))
}
} .to[F]
}
} .attempt.flatMap {
case Right(json) => F.pure(json.asRight)
case Left(err: WithViolations) => fail(formatWithViolations(err))
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.3
sbt.version=1.3.10
6 changes: 4 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0")
scalaVersion := "2.12.11"

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.0")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")