Skip to content

Commit

Permalink
update to latest caliban library versions (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpdaniels authored Dec 18, 2023
1 parent 22fd129 commit 77a1980
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 41 deletions.
2 changes: 1 addition & 1 deletion implementations/caliban/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hseeberger/scala-sbt:11.0.12_1.5.5_2.13.6 AS build
FROM sbtscala/scala-sbt:graalvm-ce-22.3.3-b1-java17_1.9.8_2.13.12 AS build

WORKDIR /build
COPY project/build.properties ./project/
Expand Down
19 changes: 7 additions & 12 deletions implementations/caliban/build.sbt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import sbt._
import sbt.*

version := "2.1.0"
scalaVersion := "2.13.8"
version := "2.4.3"
scalaVersion := "2.13.12"

val zioJsonV = "0.4.2"
val zioHttpV = "0.0.5"
val calibanV = "2.1.0" //"2.0.1"
val calibanV = "2.4.3"

libraryDependencies ++= List(
"dev.zio" %% "zio-json" % zioJsonV,
"dev.zio" %% "zio-http" % zioHttpV,
"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "1.2.11",
"com.github.ghostdogpr" %% "caliban" % calibanV,
"com.github.ghostdogpr" %% "caliban-federation" % calibanV,
"com.github.ghostdogpr" %% "caliban-zio-http" % calibanV
"com.github.ghostdogpr" %% "caliban" % calibanV,
"com.github.ghostdogpr" %% "caliban-quick" % calibanV,
"com.github.ghostdogpr" %% "caliban-federation" % calibanV
)
2 changes: 1 addition & 1 deletion implementations/caliban/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.2
sbt.version=1.9.7
27 changes: 11 additions & 16 deletions implementations/caliban/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import caliban.ZHttpAdapter
import services.{InventoryService, ProductService, UserService}
import sttp.tapir.json.zio._
import caliban.quick._
import services.{ InventoryService, ProductService, UserService }
import zio.Console.printLine
import zio.http.{Server, ServerConfig}
import zio.{ZIOAppDefault, ZLayer}
import zio.ZIOAppDefault

object Main extends ZIOAppDefault {
override def run =
(for {
_ <- printLine("Starting server")
interpreter <- ProductApi.interpreter
_ <- Server.serve(ZHttpAdapter.makeHttpService(interpreter).withDefaultErrorResponse)
} yield ()).provide(
ZLayer.succeed(ServerConfig.default.port(4001)),
Server.live,
ProductService.inMemory,
UserService.inMemory,
InventoryService.inMemory
)
printLine("Starting server") *>
ProductApi.graphql
.runServer(4001, "/")
.provide(
ProductService.inMemory,
UserService.inMemory,
InventoryService.inMemory
)
}
14 changes: 4 additions & 10 deletions implementations/caliban/src/main/scala/ProductApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import caliban.schema.{ GenericSchema, Schema }
import models._
import services.{ InventoryService, ProductService, UserService }
import zio.query.ZQuery
import zio.{ IO, URIO, ZIO }
import zio.{ URIO, ZIO }

case class Query(
product: IDArgs => URIO[ProductService, Option[models.Product]],
Expand Down Expand Up @@ -86,8 +86,8 @@ object ProductApi extends GenericSchema[ProductService with UserService] {
"custom",
None,
Set(__DirectiveLocation.OBJECT),
Nil,
repeatable = false
_ => Nil,
isRepeatable = false
)
)
) @@ federated(
Expand All @@ -96,12 +96,6 @@ object ProductApi extends GenericSchema[ProductService with UserService] {
productResearchResolver,
deprecatedProductResolver,
inventoryResolver
) @@ ApolloFederatedTracing.wrapper

val interpreter: IO[CalibanError.ValidationError, GraphQLInterpreter[
ProductService with UserService with InventoryService,
CalibanError
]] =
graphql.interpreter
) @@ ApolloFederatedTracing.wrapper()

}
2 changes: 1 addition & 1 deletion implementations/caliban/src/main/scala/models/ID.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import caliban.Value.StringValue
case class ID(id: String) extends AnyVal

object ID {
implicit val schema: Schema[Any, ID] = Schema.scalarSchema[ID]("ID", None, None, id => StringValue(id.id))
implicit val schema: Schema[Any, ID] = Schema.scalarSchema[ID]("ID", None, None, None, id => StringValue(id.id))
implicit val argBuilder: ArgBuilder[ID] = ArgBuilder.string.map(ID(_))
}

0 comments on commit 77a1980

Please sign in to comment.