diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c01725..5ef8203 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,19 @@ on: branches: ["*"] jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v2.3.1 + with: + distribution: temurin + java-version: 11 + check-latest: true + - name: Run scalafix and scalafmt + run: sbt ';scalafixAll --check ;scalafmtCheckAll ' + ci: runs-on: ubuntu-latest steps: diff --git a/.scalafmt.conf b/.scalafmt.conf index 9d17fba..ef30ca5 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ -#version = "3.0.6" -runner.dialect = scala212 +version = "3.0.6" +runner.dialect = Scala213Source3 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3 maxColumn = 140 align.preset = most continuationIndent.defnSite = 2 diff --git a/build.sbt b/build.sbt index 6654349..1b004e9 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,5 @@ import BuildHelper._ import Libraries._ -import sbt.librarymanagement.Resolver Global / onChangedBuildSource := ReloadOnSourceChanges @@ -18,8 +17,6 @@ ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaV ThisBuild / scalafixDependencies ++= List( "com.github.vovapolu" %% "scaluzzi" % "0.1.20" ) -ThisBuild / resolvers += Resolver.mavenLocal -ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots") // ### App Modules ### diff --git a/modules/app/src/main/scala/poc/caliban/app/Main.scala b/modules/app/src/main/scala/poc/caliban/app/Main.scala index 42c4a44..4d6acba 100644 --- a/modules/app/src/main/scala/poc/caliban/app/Main.scala +++ b/modules/app/src/main/scala/poc/caliban/app/Main.scala @@ -9,7 +9,6 @@ import zio.magic._ import zio.{ExitCode, Has, RIO, URIO, ZEnv, ZManaged} object Main extends zio.App { - import org.http4s.implicits._ import zio.interop.catz._ type R = ZEnv with Has[PostService] @@ -20,10 +19,10 @@ object Main extends zio.App { interpreter <- ZManaged.fromEffect(poc.caliban.posts.GraphQLApi.api.interpreter) _ <- BlazeServerBuilder[LocalTask] .bindHttp(8080, "0.0.0.0") - .withHttpApp( + .withHttpWebSocketApp(builder => Router[LocalTask]( "/api/graphql" -> Http4sAdapter.makeHttpService(interpreter), - "/ws/graphql" -> Http4sAdapter.makeWebSocketService(interpreter), + "/ws/graphql" -> Http4sAdapter.makeWebSocketService(builder, interpreter), "/graphiql" -> HttpRoutes.liftF(StaticFile.fromResource("/graphiql.html", None)) ).orNotFound ) diff --git a/modules/caliban-clients/src/main/scala/generated/Client.scala b/modules/caliban-clients/src/main/scala/generated/Client.scala new file mode 100644 index 0000000..d2ed16b --- /dev/null +++ b/modules/caliban-clients/src/main/scala/generated/Client.scala @@ -0,0 +1,103 @@ +package generated + +import caliban.client.FieldBuilder._ +import caliban.client._ +import caliban.client.__Value._ + +object Client { + + type ID = String + + type AuthorName + object AuthorName { + def name: SelectionBuilder[AuthorName, String] = _root_.caliban.client.SelectionBuilder.Field("name", Scalar()) + } + + type PostId + object PostId { + def id: SelectionBuilder[PostId, String] = _root_.caliban.client.SelectionBuilder.Field("id", Scalar()) + } + + type PostContent + object PostContent { + def content: SelectionBuilder[PostContent, String] = _root_.caliban.client.SelectionBuilder.Field("content", Scalar()) + } + + type PostTitle + object PostTitle { + def title: SelectionBuilder[PostTitle, String] = _root_.caliban.client.SelectionBuilder.Field("title", Scalar()) + } + + type Post + object Post { + def id[A](innerSelection: SelectionBuilder[PostId, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("id", Obj(innerSelection)) + def author[A](innerSelection: SelectionBuilder[AuthorName, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("author", Obj(innerSelection)) + def title[A](innerSelection: SelectionBuilder[PostTitle, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("title", Obj(innerSelection)) + def content[A](innerSelection: SelectionBuilder[PostContent, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("content", Obj(innerSelection)) + } + + case class PostContentInput(content: String) + object PostContentInput { + implicit val encoder: ArgEncoder[PostContentInput] = new ArgEncoder[PostContentInput] { + override def encode(value: PostContentInput): __Value = + __ObjectValue(List("content" -> implicitly[ArgEncoder[String]].encode(value.content))) + } + } + case class AuthorNameInput(name: String) + object AuthorNameInput { + implicit val encoder: ArgEncoder[AuthorNameInput] = new ArgEncoder[AuthorNameInput] { + override def encode(value: AuthorNameInput): __Value = + __ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(value.name))) + } + } + case class PostTitleInput(title: String) + object PostTitleInput { + implicit val encoder: ArgEncoder[PostTitleInput] = new ArgEncoder[PostTitleInput] { + override def encode(value: PostTitleInput): __Value = + __ObjectValue(List("title" -> implicitly[ArgEncoder[String]].encode(value.title))) + } + } + type Query = _root_.caliban.client.Operations.RootQuery + object Query { + def postById[A](id: String)(innerSelection: SelectionBuilder[Post, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("postById", OptionOf(Obj(innerSelection)), arguments = List(Argument("id", id, "ID!")(encoder0))) + } + + type Mutation = _root_.caliban.client.Operations.RootMutation + object Mutation { + def createPost[A](authorName: AuthorNameInput, title: PostTitleInput, content: PostContentInput)( + innerSelection: SelectionBuilder[Post, A] + )(implicit + encoder0: ArgEncoder[AuthorNameInput], + encoder1: ArgEncoder[PostTitleInput], + encoder2: ArgEncoder[PostContentInput] + ): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field( + "createPost", + OptionOf(Obj(innerSelection)), + arguments = List( + Argument("authorName", authorName, "AuthorNameInput!")(encoder0), + Argument("title", title, "PostTitleInput!")(encoder1), + Argument("content", content, "PostContentInput!")(encoder2) + ) + ) + def deletePost( + id: String + )(implicit encoder0: ArgEncoder[String]): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] = + _root_.caliban.client.SelectionBuilder.Field("deletePost", OptionOf(Scalar()), arguments = List(Argument("id", id, "ID!")(encoder0))) + } + + type Subscription = _root_.caliban.client.Operations.RootSubscription + object Subscription { + def allPostsByAuthor[A](name: String)(innerSelection: SelectionBuilder[Post, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootSubscription, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("allPostsByAuthor", OptionOf(Obj(innerSelection)), arguments = List(Argument("name", name, "String!")(encoder0))) + } + +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/CalibanClient.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/CalibanClient.scala new file mode 100644 index 0000000..d3f2f93 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/CalibanClient.scala @@ -0,0 +1,103 @@ +package poc.caliban.client.generated.posts + +import caliban.client.FieldBuilder._ +import caliban.client._ +import caliban.client.__Value._ + +object CalibanClient { + + type ID = String + + type AuthorName + object AuthorName { + def name: SelectionBuilder[AuthorName, String] = _root_.caliban.client.SelectionBuilder.Field("name", Scalar()) + } + + type PostId + object PostId { + def id: SelectionBuilder[PostId, String] = _root_.caliban.client.SelectionBuilder.Field("id", Scalar()) + } + + type PostContent + object PostContent { + def content: SelectionBuilder[PostContent, String] = _root_.caliban.client.SelectionBuilder.Field("content", Scalar()) + } + + type PostTitle + object PostTitle { + def title: SelectionBuilder[PostTitle, String] = _root_.caliban.client.SelectionBuilder.Field("title", Scalar()) + } + + type Post + object Post { + def id[A](innerSelection: SelectionBuilder[PostId, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("id", Obj(innerSelection)) + def author[A](innerSelection: SelectionBuilder[AuthorName, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("author", Obj(innerSelection)) + def title[A](innerSelection: SelectionBuilder[PostTitle, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("title", Obj(innerSelection)) + def content[A](innerSelection: SelectionBuilder[PostContent, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("content", Obj(innerSelection)) + } + + case class PostContentInput(content: String) + object PostContentInput { + implicit val encoder: ArgEncoder[PostContentInput] = new ArgEncoder[PostContentInput] { + override def encode(value: PostContentInput): __Value = + __ObjectValue(List("content" -> implicitly[ArgEncoder[String]].encode(value.content))) + } + } + case class AuthorNameInput(name: String) + object AuthorNameInput { + implicit val encoder: ArgEncoder[AuthorNameInput] = new ArgEncoder[AuthorNameInput] { + override def encode(value: AuthorNameInput): __Value = + __ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(value.name))) + } + } + case class PostTitleInput(title: String) + object PostTitleInput { + implicit val encoder: ArgEncoder[PostTitleInput] = new ArgEncoder[PostTitleInput] { + override def encode(value: PostTitleInput): __Value = + __ObjectValue(List("title" -> implicitly[ArgEncoder[String]].encode(value.title))) + } + } + type Query = _root_.caliban.client.Operations.RootQuery + object Query { + def postById[A](id: String)(innerSelection: SelectionBuilder[Post, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("postById", OptionOf(Obj(innerSelection)), arguments = List(Argument("id", id, "ID!")(encoder0))) + } + + type Mutation = _root_.caliban.client.Operations.RootMutation + object Mutation { + def createPost[A](authorName: AuthorNameInput, title: PostTitleInput, content: PostContentInput)( + innerSelection: SelectionBuilder[Post, A] + )(implicit + encoder0: ArgEncoder[AuthorNameInput], + encoder1: ArgEncoder[PostTitleInput], + encoder2: ArgEncoder[PostContentInput] + ): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field( + "createPost", + OptionOf(Obj(innerSelection)), + arguments = List( + Argument("authorName", authorName, "AuthorNameInput!")(encoder0), + Argument("title", title, "PostTitleInput!")(encoder1), + Argument("content", content, "PostContentInput!")(encoder2) + ) + ) + def deletePost( + id: String + )(implicit encoder0: ArgEncoder[String]): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] = + _root_.caliban.client.SelectionBuilder.Field("deletePost", OptionOf(Scalar()), arguments = List(Argument("id", id, "ID!")(encoder0))) + } + + type Subscription = _root_.caliban.client.Operations.RootSubscription + object Subscription { + def allPostsByAuthor[A](name: String)(innerSelection: SelectionBuilder[Post, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootSubscription, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("allPostsByAuthor", OptionOf(Obj(innerSelection)), arguments = List(Argument("name", name, "String!")(encoder0))) + } + +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/AuthorName.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/AuthorName.scala new file mode 100644 index 0000000..17bfd44 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/AuthorName.scala @@ -0,0 +1,8 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object AuthorName { + def name: SelectionBuilder[AuthorName, String] = _root_.caliban.client.SelectionBuilder.Field("name", Scalar()) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/AuthorNameInput.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/AuthorNameInput.scala new file mode 100644 index 0000000..3973265 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/AuthorNameInput.scala @@ -0,0 +1,12 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client._ +import caliban.client.__Value._ + +case class AuthorNameInput(name: String) +object AuthorNameInput { + implicit val encoder: ArgEncoder[AuthorNameInput] = new ArgEncoder[AuthorNameInput] { + override def encode(value: AuthorNameInput): __Value = + __ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(value.name))) + } +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Mutation.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Mutation.scala new file mode 100644 index 0000000..a401760 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Mutation.scala @@ -0,0 +1,26 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Mutation { + def createPost[A](authorName: AuthorNameInput, title: PostTitleInput, content: PostContentInput)( + innerSelection: SelectionBuilder[Post, A] + )(implicit + encoder0: ArgEncoder[AuthorNameInput], + encoder1: ArgEncoder[PostTitleInput], + encoder2: ArgEncoder[PostContentInput] + ): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field( + "createPost", + OptionOf(Obj(innerSelection)), + arguments = List( + Argument("authorName", authorName, "AuthorNameInput!")(encoder0), + Argument("title", title, "PostTitleInput!")(encoder1), + Argument("content", content, "PostContentInput!")(encoder2) + ) + ) + def deletePost( + id: String + )(implicit encoder0: ArgEncoder[String]): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] = + _root_.caliban.client.SelectionBuilder.Field("deletePost", OptionOf(Scalar()), arguments = List(Argument("id", id, "ID!")(encoder0))) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Post.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Post.scala new file mode 100644 index 0000000..974d387 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Post.scala @@ -0,0 +1,15 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Post { + def id[A](innerSelection: SelectionBuilder[PostId, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("id", Obj(innerSelection)) + def author[A](innerSelection: SelectionBuilder[AuthorName, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("author", Obj(innerSelection)) + def title[A](innerSelection: SelectionBuilder[PostTitle, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("title", Obj(innerSelection)) + def content[A](innerSelection: SelectionBuilder[PostContent, A]): SelectionBuilder[Post, A] = + _root_.caliban.client.SelectionBuilder.Field("content", Obj(innerSelection)) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostContent.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostContent.scala new file mode 100644 index 0000000..be0032b --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostContent.scala @@ -0,0 +1,8 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object PostContent { + def content: SelectionBuilder[PostContent, String] = _root_.caliban.client.SelectionBuilder.Field("content", Scalar()) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostContentInput.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostContentInput.scala new file mode 100644 index 0000000..bc02b11 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostContentInput.scala @@ -0,0 +1,12 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client._ +import caliban.client.__Value._ + +case class PostContentInput(content: String) +object PostContentInput { + implicit val encoder: ArgEncoder[PostContentInput] = new ArgEncoder[PostContentInput] { + override def encode(value: PostContentInput): __Value = + __ObjectValue(List("content" -> implicitly[ArgEncoder[String]].encode(value.content))) + } +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostId.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostId.scala new file mode 100644 index 0000000..660c970 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostId.scala @@ -0,0 +1,8 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object PostId { + def id: SelectionBuilder[PostId, String] = _root_.caliban.client.SelectionBuilder.Field("id", Scalar()) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostTitle.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostTitle.scala new file mode 100644 index 0000000..b0d9210 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostTitle.scala @@ -0,0 +1,8 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object PostTitle { + def title: SelectionBuilder[PostTitle, String] = _root_.caliban.client.SelectionBuilder.Field("title", Scalar()) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostTitleInput.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostTitleInput.scala new file mode 100644 index 0000000..bfdd978 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/PostTitleInput.scala @@ -0,0 +1,12 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client._ +import caliban.client.__Value._ + +case class PostTitleInput(title: String) +object PostTitleInput { + implicit val encoder: ArgEncoder[PostTitleInput] = new ArgEncoder[PostTitleInput] { + override def encode(value: PostTitleInput): __Value = + __ObjectValue(List("title" -> implicitly[ArgEncoder[String]].encode(value.title))) + } +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Query.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Query.scala new file mode 100644 index 0000000..693eefc --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Query.scala @@ -0,0 +1,11 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Query { + def postById[A](id: String)(innerSelection: SelectionBuilder[Post, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("postById", OptionOf(Obj(innerSelection)), arguments = List(Argument("id", id, "ID!")(encoder0))) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Subscription.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Subscription.scala new file mode 100644 index 0000000..d41bb33 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/Subscription.scala @@ -0,0 +1,11 @@ +package poc.caliban.client.generated.posts.splitted + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Subscription { + def allPostsByAuthor[A](name: String)(innerSelection: SelectionBuilder[Post, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootSubscription, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("allPostsByAuthor", OptionOf(Obj(innerSelection)), arguments = List(Argument("name", name, "String!")(encoder0))) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/package.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/package.scala new file mode 100644 index 0000000..56e98c7 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/posts/splitted/package.scala @@ -0,0 +1,14 @@ +package poc.caliban.client.generated.posts + +package object splitted { + type ID = String + + type AuthorName + type PostId + type PostContent + type PostTitle + type Post + type Query = _root_.caliban.client.Operations.RootQuery + type Mutation = _root_.caliban.client.Operations.RootMutation + type Subscription = _root_.caliban.client.Operations.RootSubscription +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Color.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Color.scala new file mode 100644 index 0000000..0f4b076 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Color.scala @@ -0,0 +1,29 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client.CalibanClientError.DecodingError +import caliban.client._ +import caliban.client.__Value._ + +sealed trait Color extends scala.Product with scala.Serializable { def value: String } +object Color { + case object Purple extends Color { val value: String = "Purple" } + case object Red extends Color { val value: String = "Red" } + case object White extends Color { val value: String = "White" } + case object Yellow extends Color { val value: String = "Yellow" } + + implicit val decoder: ScalarDecoder[Color] = { + case __StringValue("Purple") => Right(Color.Purple) + case __StringValue("Red") => Right(Color.Red) + case __StringValue("White") => Right(Color.White) + case __StringValue("Yellow") => Right(Color.Yellow) + case other => Left(DecodingError(s"Can't build Color from input $other")) + } + implicit val encoder: ArgEncoder[Color] = { + case Color.Purple => __EnumValue("Purple") + case Color.Red => __EnumValue("Red") + case Color.White => __EnumValue("White") + case Color.Yellow => __EnumValue("Yellow") + } + + val values: Vector[Color] = Vector(Purple, Red, White, Yellow) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Mutation.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Mutation.scala new file mode 100644 index 0000000..cdb946e --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Mutation.scala @@ -0,0 +1,19 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Mutation { + def makeNewSpecies[A](name: NameInput, color: Color)(innerSelection: SelectionBuilder[Potato, A])(implicit + encoder0: ArgEncoder[NameInput], + encoder1: ArgEncoder[Color] + ): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field( + "makeNewSpecies", + OptionOf(Obj(innerSelection)), + arguments = List(Argument("name", name, "NameInput!")(encoder0), Argument("color", color, "Color!")(encoder1)) + ) + def eradicate(value: String)(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] = _root_.caliban.client.SelectionBuilder + .Field("eradicate", OptionOf(Scalar()), arguments = List(Argument("value", value, "String!")(encoder0))) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Name.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Name.scala new file mode 100644 index 0000000..4279bd1 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Name.scala @@ -0,0 +1,8 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Name { + def value: SelectionBuilder[Name, String] = _root_.caliban.client.SelectionBuilder.Field("value", Scalar()) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/NameInput.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/NameInput.scala new file mode 100644 index 0000000..4b43073 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/NameInput.scala @@ -0,0 +1,12 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client._ +import caliban.client.__Value._ + +case class NameInput(value: String) +object NameInput { + implicit val encoder: ArgEncoder[NameInput] = new ArgEncoder[NameInput] { + override def encode(value: NameInput): __Value = + __ObjectValue(List("value" -> implicitly[ArgEncoder[String]].encode(value.value))) + } +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Potato.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Potato.scala new file mode 100644 index 0000000..6818daf --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Potato.scala @@ -0,0 +1,10 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Potato { + def name[A](innerSelection: SelectionBuilder[Name, A]): SelectionBuilder[Potato, A] = + _root_.caliban.client.SelectionBuilder.Field("name", Obj(innerSelection)) + def color: SelectionBuilder[Potato, Color] = _root_.caliban.client.SelectionBuilder.Field("color", Scalar()) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Query.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Query.scala new file mode 100644 index 0000000..d9335cc --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Query.scala @@ -0,0 +1,15 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Query { + def byName[A](value: String)(innerSelection: SelectionBuilder[Potato, A])(implicit + encoder0: ArgEncoder[String] + ): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[A]] = _root_.caliban.client.SelectionBuilder + .Field("byName", OptionOf(Obj(innerSelection)), arguments = List(Argument("value", value, "String!")(encoder0))) + def byColor[A](value: Color)(innerSelection: SelectionBuilder[Potato, A])(implicit + encoder0: ArgEncoder[Color] + ): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[List[A]]] = _root_.caliban.client.SelectionBuilder + .Field("byColor", OptionOf(ListOf(Obj(innerSelection))), arguments = List(Argument("value", value, "Color!")(encoder0))) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Subscription.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Subscription.scala new file mode 100644 index 0000000..051a0d7 --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/Subscription.scala @@ -0,0 +1,11 @@ +package poc.caliban.client.generated.potatoes + +import caliban.client.FieldBuilder._ +import caliban.client._ + +object Subscription { + def allPotatoes[A]( + innerSelection: SelectionBuilder[Potato, A] + ): SelectionBuilder[_root_.caliban.client.Operations.RootSubscription, Option[A]] = + _root_.caliban.client.SelectionBuilder.Field("allPotatoes", OptionOf(Obj(innerSelection))) +} diff --git a/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/package.scala b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/package.scala new file mode 100644 index 0000000..e3ed4ca --- /dev/null +++ b/modules/caliban-clients/src/main/scala/poc/caliban/client/generated/potatoes/package.scala @@ -0,0 +1,9 @@ +package poc.caliban.client.generated + +package object potatoes { + type Potato + type Name + type Query = _root_.caliban.client.Operations.RootQuery + type Mutation = _root_.caliban.client.Operations.RootMutation + type Subscription = _root_.caliban.client.Operations.RootSubscription +} diff --git a/project/Libraries.scala b/project/Libraries.scala index cc7dfcd..8bd29e9 100644 --- a/project/Libraries.scala +++ b/project/Libraries.scala @@ -2,7 +2,7 @@ import sbt._ object Libraries { - val calibanVersion = "1.1.1+50-05877d73-SNAPSHOT" + val calibanVersion = "1.2.0" val sttpVersion = "3.3.15" val http4sVersion = "0.23.5" val zioVersion = "1.0.12" diff --git a/project/plugins.sbt b/project/plugins.sbt index bc48a24..fcdd7c9 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,8 +1,3 @@ -import sbt.librarymanagement.Resolver - -resolvers += Resolver.mavenLocal -resolvers += Resolver.sonatypeRepo("snapshots") - addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.5") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") @@ -12,4 +7,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.9") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.0") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("com.github.ghostdogpr" % "caliban-codegen-sbt" % "1.1.1+57-dbf9bef1-SNAPSHOT") +addSbtPlugin("com.github.ghostdogpr" % "caliban-codegen-sbt" % "1.2.0")